diff --git a/IQKeyBoardManager/Categories/IQUIWindow+Hierarchy.m b/IQKeyBoardManager/Categories/IQUIWindow+Hierarchy.m index f9b4023..fe32214 100644 --- a/IQKeyBoardManager/Categories/IQUIWindow+Hierarchy.m +++ b/IQKeyBoardManager/Categories/IQUIWindow+Hierarchy.m @@ -26,7 +26,7 @@ @implementation UIWindow (IQ_UIWindow_Hierarchy) -- (UIViewController*) topMostController +- (UIViewController*)topMostController { UIViewController *topController = [self rootViewController]; diff --git a/IQKeyBoardManager/IQKeyboardManager.m b/IQKeyBoardManager/IQKeyboardManager.m index 1516d22..f3dd35e 100644 --- a/IQKeyBoardManager/IQKeyboardManager.m +++ b/IQKeyBoardManager/IQKeyboardManager.m @@ -247,11 +247,12 @@ void _IQShowLog(NSString *logString); //Creating gesture for @shouldResignOnTouchOutside. (Enhancement ID: #14) _tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognized:)]; [_tapGesture setDelegate:self]; - + _tapGesture.enabled = _shouldResignOnTouchOutside; + //Setting it's initial values _enable = NO; //This enables in +(void)load method. _animationDuration = 0.25; - _animationCurve = 7<<16; + _animationCurve = UIViewAnimationCurveEaseInOut; [self setKeyboardDistanceFromTextField:10.0]; _defaultToolbarTintColor = [UIColor blackColor]; [self setCanAdjustTextView:NO]; @@ -712,6 +713,7 @@ void _IQShowLog(NSString *logString); } completion:NULL]; + //Maintaining contentSize if (_lastScrollView.contentSize.height<_lastScrollView.frame.size.height) { CGSize contentSize = _lastScrollView.contentSize; @@ -962,7 +964,7 @@ void _IQShowLog(NSString *logString); } else { - _animationCurve = 0; + _animationCurve = UIViewAnimationOptionsCurveEaseOut } // Getting keyboard animation duration @@ -1082,15 +1084,16 @@ void _IQShowLog(NSString *logString); #ifdef NSFoundationVersionNumber_iOS_5_1 - if([[_textFieldView viewController] IQLayoutGuideConstraint]) + NSLayoutConstraint *constraint = [[_textFieldView viewController] IQLayoutGuideConstraint]; + + //If done LayoutGuide tweak + if (constraint && + ((constraint.firstItem == [[_textFieldView viewController] topLayoutGuide] || constraint.secondItem == [[_textFieldView viewController] topLayoutGuide]) || + (constraint.firstItem == [[_textFieldView viewController] bottomLayoutGuide] || constraint.secondItem == [[_textFieldView viewController] bottomLayoutGuide]))) { - NSLayoutConstraint *constraint = [[_textFieldView viewController] IQLayoutGuideConstraint]; - - [UIView animateWithDuration:_animationDuration delay:0 options:(7<<16|UIViewAnimationOptionBeginFromCurrentState) animations:^{ - constraint.constant = _layoutGuideConstraintInitialConstant; - [_rootViewController.view setNeedsLayout]; - [_rootViewController.view layoutIfNeeded]; - } completion:NULL]; + constraint.constant = _layoutGuideConstraintInitialConstant; + [_rootViewController.view setNeedsLayout]; + [_rootViewController.view layoutIfNeeded]; } else #endif @@ -1579,8 +1582,7 @@ void _IQShowLog(NSString *logString); UITextField *textField = nil; if ([siblings count]) - textField = [siblings objectAtIndex:0]; - + textField = [siblings objectAtIndex:0]; //Not using firstObject method because iOS5 doesn't not support 'firstObject' method. //Either there is no inputAccessoryView or if accessoryView is not appropriate for current situation(There is Previous/Next/Done toolbar). if (![textField inputAccessoryView] || ([[textField inputAccessoryView] tag] == kIQPreviousNextButtonToolbarTag)) diff --git a/IQKeybordManagerSwift/Categories/IQUITextFieldView+Additions.swift b/IQKeybordManagerSwift/Categories/IQUITextFieldView+Additions.swift new file mode 100644 index 0000000..4b15ca9 --- /dev/null +++ b/IQKeybordManagerSwift/Categories/IQUITextFieldView+Additions.swift @@ -0,0 +1,56 @@ +// +// IQUITextFieldView+Additions.swift +// https://github.com/hackiftekhar/IQKeyboardManager +// Copyright (c) 2013-15 Iftekhar Qurashi. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation +import UIKit + +/** +Uses default keyboard distance for textField. +*/ +let kIQUseDefaultKeyboardDistance = CGFloat.max + +private var kIQKeyboardDistanceFromTextField = "kIQKeyboardDistanceFromTextField" + +/** +UIView category for managing UITextField/UITextView +*/ +extension UIView { + + /** + To set customized distance from keyboard for textField/textView. Can't be less than zero + */ + var keyboardDistanceFromTextField: CGFloat { + get { + + if let aValue = objc_getAssociatedObject(self, &kIQKeyboardDistanceFromTextField) as? CGFloat { + return aValue + } else { + return kIQUseDefaultKeyboardDistance + } + } + set(newValue) { + objc_setAssociatedObject(self, &kIQKeyboardDistanceFromTextField, newValue, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC)) + } + } +} + diff --git a/IQKeybordManagerSwift/Categories/IQUIView+Hierarchy.swift b/IQKeybordManagerSwift/Categories/IQUIView+Hierarchy.swift index 4e8922b..174f12e 100644 --- a/IQKeybordManagerSwift/Categories/IQUIView+Hierarchy.swift +++ b/IQKeybordManagerSwift/Categories/IQUIView+Hierarchy.swift @@ -25,6 +25,8 @@ import Foundation import UIKit +private var kIQIsAskingCanBecomeFirstResponder = "kIQIsAskingCanBecomeFirstResponder" + /** UIView hierarchy category. */ @@ -40,14 +42,14 @@ extension UIView { var isAskingCanBecomeFirstResponder: Bool { get { - if let aValue = objc_getAssociatedObject(self, "isAskingCanBecomeFirstResponder") as? Bool { + if let aValue = objc_getAssociatedObject(self, &kIQIsAskingCanBecomeFirstResponder) as? Bool { return aValue } else { return false } } set(newValue) { - objc_setAssociatedObject(self, "isAskingCanBecomeFirstResponder", newValue, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC)) + objc_setAssociatedObject(self, &kIQIsAskingCanBecomeFirstResponder, newValue, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC)) } } @@ -218,18 +220,19 @@ extension UIView { var _IQcanBecomeFirstResponder = (canBecomeFirstResponder() == true && userInteractionEnabled == true && hidden == false && alpha != 0.0 && isAlertViewTextField() == false && isSearchBarTextField() == false) as Bool - // Setting toolbar to keyboard. - if let textField = self as? UITextField { - _IQcanBecomeFirstResponder = textField.enabled - } else if let textView = self as? UITextView { - _IQcanBecomeFirstResponder = textView.editable + if _IQcanBecomeFirstResponder == true { + // Setting toolbar to keyboard. + if let textField = self as? UITextField { + _IQcanBecomeFirstResponder = textField.enabled + } else if let textView = self as? UITextView { + _IQcanBecomeFirstResponder = textView.editable + } } isAskingCanBecomeFirstResponder = false return _IQcanBecomeFirstResponder } - ///------------------------- /// MARK: Special TextFields diff --git a/IQKeybordManagerSwift/Categories/IQUIViewController+Additions.swift b/IQKeybordManagerSwift/Categories/IQUIViewController+Additions.swift new file mode 100644 index 0000000..a77e037 --- /dev/null +++ b/IQKeybordManagerSwift/Categories/IQUIViewController+Additions.swift @@ -0,0 +1,46 @@ +// +// IQUIViewController+Additions.swift +// https://github.com/hackiftekhar/IQKeyboardManager +// Copyright (c) 2013-15 Iftekhar Qurashi. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation +import UIKit + + +private var kIQLayoutGuideConstraint = "kIQLayoutGuideConstraint" + + +extension UIViewController { + + /** + To set customized distance from keyboard for textField/textView. Can't be less than zero + */ + @IBOutlet var IQLayoutGuideConstraint: NSLayoutConstraint? { + get { + + return objc_getAssociatedObject(self, &kIQLayoutGuideConstraint) as? NSLayoutConstraint + } + + set(newValue) { + objc_setAssociatedObject(self, &kIQLayoutGuideConstraint, newValue, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC)) + } + } +} \ No newline at end of file diff --git a/IQKeybordManagerSwift/IQKeyboardManager.swift b/IQKeybordManagerSwift/IQKeyboardManager.swift index 0f47d91..991b536 100644 --- a/IQKeybordManagerSwift/IQKeyboardManager.swift +++ b/IQKeybordManagerSwift/IQKeyboardManager.swift @@ -33,12 +33,12 @@ import UIKit /** Default tag for toolbar with Done button -1002. */ -let kIQDoneButtonToolbarTag : Int = -1002 +let kIQDoneButtonToolbarTag = -1002 /** Default tag for toolbar with Previous/Next buttons -1005. */ -let kIQPreviousNextButtonToolbarTag : Int = -1005 +let kIQPreviousNextButtonToolbarTag = -1005 /** Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView. Neither need to write any code nor any setup required and much more. A generic version of KeyboardManagement. https://developer.apple.com/Library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html @@ -54,7 +54,7 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { /** Enable/disable managing distance between keyboard and textField. Default is YES(Enabled when class loads in `+(void)load` method). */ - var enable: Bool = false { + var enable = false { didSet { //If not enable, enable it. @@ -104,7 +104,6 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { return Static.kbManager } - ///------------------------- /// MARK: IQToolbar handling ///------------------------- @@ -112,7 +111,7 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { /** Automatic add the IQToolbar functionality. Default is YES. */ - var enableAutoToolbar: Bool = true { + var enableAutoToolbar = true { didSet { @@ -183,7 +182,7 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { /** Resigns Keyboard on touching outside of UITextField/View. Default is NO. */ - var shouldResignOnTouchOutside: Bool = false { + var shouldResignOnTouchOutside = false { didSet { _tapGesture.enabled = shouldResignOnTouchOutside @@ -197,7 +196,7 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { /** Resigns currently first responder field. */ - func resignFirstResponder() { + func resignFirstResponder()-> Bool { if let textFieldRetain = _textFieldView { @@ -211,7 +210,11 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { _IQShowLog("Refuses to resign first responder: \(_textFieldView?._IQDescription())") } + + return isResignFirstResponder; } + + return false } /** @@ -268,11 +271,11 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { /** Navigate to previous responder textField/textView. */ - func goPrevious() { + func goPrevious()-> Bool { //Getting all responder view's. - if let textFields = responderViews() { - if let textFieldRetain = _textFieldView { + if let textFieldRetain = _textFieldView { + if let textFields = responderViews() { if textFields.containsObject(textFieldRetain) == true { //Getting index of current textField. let index = textFields.indexOfObject(textFieldRetain) @@ -291,20 +294,24 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { _IQShowLog("Refuses to become first responder: \(nextTextField._IQDescription())") } + + return isAcceptAsFirstResponder } } } } + + return false } /** Navigate to next responder textField/textView. */ - func goNext() { + func goNext()-> Bool { //Getting all responder view's. - if let textFields = responderViews() { - if let textFieldRetain = _textFieldView { + if let textFieldRetain = _textFieldView { + if let textFields = responderViews() { if textFields.containsObject(textFieldRetain) == true { //Getting index of current textField. @@ -324,10 +331,14 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { _IQShowLog("Refuses to become first responder: \(nextTextField._IQDescription())") } + + return isAcceptAsFirstResponder } } } } + + return false } /** previousAction. */ @@ -340,7 +351,14 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { } if canGoPrevious == true { - goPrevious() + + if let textFieldRetain = _textFieldView { + let isAcceptAsFirstResponder = goPrevious() + +// if isAcceptAsFirstResponder && textFieldRetain.previousInvocation == nil { +// textFieldRetain.previousInvocation.invoke() +// } + } } } @@ -353,8 +371,15 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { UIDevice.currentDevice().playInputClick() } - if canGoNext { - goNext() + if canGoNext == true { + + if let textFieldRetain = _textFieldView { + let isAcceptAsFirstResponder = goNext() + +// if isAcceptAsFirstResponder && textFieldRetain.nextInvocation == nil { +// textFieldRetain.nextInvocation.invoke() +// } + } } } @@ -367,16 +392,23 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { UIDevice.currentDevice().playInputClick() } - //Resign textFieldView. - resignFirstResponder() + if let textFieldRetain = _textFieldView { + //Resign textFieldView. + let isResignedFirstResponder = resignFirstResponder() + +// if isResignedFirstResponder && textFieldRetain.doneInvocation == nil { +// textFieldRetain.doneInvocation.invoke() +// } + } } /** Resigning on tap gesture. (Enhancement ID: #14)*/ func tapRecognized(gesture: UITapGestureRecognizer) { if gesture.state == UIGestureRecognizerState.Ended { + //Resigning currently responder textField. - gesture.view?.endEditing(true) + resignFirstResponder() } } @@ -532,9 +564,9 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { /** To save rootViewController */ private weak var _rootViewController: UIViewController? - /** used with canAdjustTextView to detect a textFieldView frame is changes or not. (Bug ID: #92)*/ - private var _isTextFieldViewFrameChanged = false - + /** To save topBottomLayoutConstraint original constant */ + private var _layoutGuideConstraintInitialConstant: CGFloat = 0.25 + /*******************************************/ /** Variable to save lastScrollView that was scrolled. */ @@ -563,9 +595,6 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { /** To mimic the keyboard animation */ private var _animationCurve = UIViewAnimationOptions.CurveEaseOut - /** Boolean to maintain keyboard is showing or it is hide. To solve rootViewController.view.frame calculations. */ - private var _isKeyboardShowing = false - /*******************************************/ /** TapGesture to resign keyboard on view's touch. */ @@ -579,22 +608,31 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { /*******************************************/ /** Set of restricted classes for library */ - private var _disabledClasses = NSMutableSet() + private var _disabledClasses = NSMutableSet() /** Set of restricted classes for adding toolbar */ - private var _disabledToolbarClasses = NSMutableSet() + private var _disabledToolbarClasses = NSMutableSet() /** Set of permitted classes to add all inner textField as siblings */ - private var _toolbarPreviousNextConsideredClass = NSMutableSet() + private var _toolbarPreviousNextConsideredClass = NSMutableSet() /*******************************************/ + private struct flags { + /** used with canAdjustTextView to detect a textFieldView frame is changes or not. (Bug ID: #92)*/ + var isTextFieldViewFrameChanged = false + /** Boolean to maintain keyboard is showing or it is hide. To solve rootViewController.view.frame calculations. */ + var isKeyboardShowing = false + } + + /** Private flags to use within the project */ + private var _keyboardManagerFlags = flags(isTextFieldViewFrameChanged: false, isKeyboardShowing: false) + /** To use with keyboardDistanceFromTextField. */ private var _privateKeyboardDistanceFromTextField: CGFloat = 10.0 /**************************************************************************************/ - ///-------------------------------------- /// MARK: Initialization/Deinitialization ///-------------------------------------- @@ -632,8 +670,8 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { _toolbarPreviousNextConsideredClass.addObject(NSStringFromClass(UICollectionView)) } - /** Override +load method to enable KeyboardManager when class loader load IQKeyboardManager. Enabling when app starts (No need to write any code) */ + /** It doesn't work on Swift 1.2 */ // override class func load() { // super.load() // @@ -652,8 +690,8 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { /** Getting keyWindow. */ private func keyWindow() -> UIWindow? { - if _textFieldView?.window != nil { - return _textFieldView?.window + if let keyWindow = _textFieldView?.window { + return keyWindow } else { struct Static { @@ -675,8 +713,7 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { return Static.keyWindow } } - - + ///----------------------- /// MARK: Helper Functions ///----------------------- @@ -717,7 +754,7 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { _IQShowLog("You must set UIWindow.rootViewController in your AppDelegate to work with IQKeyboardManager") } } - + /* Adjusting RootViewController's frame according to device orientation. */ private func adjustFrame() { @@ -726,10 +763,12 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { return } + let textFieldView = _textFieldView! + _IQShowLog("****** \(__FUNCTION__) %@ started ******") // Boolean to know keyboard is showing/hiding - _isKeyboardShowing = true + _keyboardManagerFlags.isKeyboardShowing = true // Getting KeyWindow object. let optionalWindow = keyWindow() @@ -741,7 +780,7 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { } // Converting Rectangle according to window bounds. - let optionalTextFieldViewRect = _textFieldView?.superview?.convertRect(_textFieldView!.frame, toView: optionalWindow) + let optionalTextFieldViewRect = textFieldView.superview?.convertRect(textFieldView.frame, toView: optionalWindow) if optionalRootController == nil || optionalWindow == nil || optionalTextFieldViewRect == nil { return @@ -749,7 +788,6 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { let rootController = optionalRootController! let window = optionalWindow! - let textFieldView = _textFieldView! let textFieldViewRect = optionalTextFieldViewRect! //If it's iOS8 then we should do calculations according to portrait orientations. // (Bug ID: #64, #66) @@ -757,17 +795,21 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { // Getting RootViewRect. var rootViewRect = rootController.view.frame - //Getting statusBarFrame var topLayoutGuide : CGFloat = 0 + //Maintain keyboardDistanceFromTextField + let newKeyboardDistanceFromTextField = (textFieldView.keyboardDistanceFromTextField == kIQUseDefaultKeyboardDistance) ? keyboardDistanceFromTextField : textFieldView.keyboardDistanceFromTextField + var kbSize = _kbSize; let statusBarFrame = UIApplication.sharedApplication().statusBarFrame switch interfaceOrientation { case UIInterfaceOrientation.LandscapeLeft, UIInterfaceOrientation.LandscapeRight: topLayoutGuide = CGRectGetWidth(statusBarFrame) + kbSize.width += newKeyboardDistanceFromTextField case UIInterfaceOrientation.Portrait, UIInterfaceOrientation.PortraitUpsideDown: topLayoutGuide = CGRectGetHeight(statusBarFrame) + kbSize.height += newKeyboardDistanceFromTextField default: break } @@ -778,20 +820,20 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { // Calculating move position. Common for both normal and special cases. switch interfaceOrientation { case UIInterfaceOrientation.LandscapeLeft: - move = min(CGRectGetMinX(textFieldViewRect)-(topLayoutGuide+5), CGRectGetMaxX(textFieldViewRect)-(CGRectGetWidth(window.frame)-_kbSize.width)) + move = min(CGRectGetMinX(textFieldViewRect)-(topLayoutGuide+5), CGRectGetMaxX(textFieldViewRect)-(CGRectGetWidth(window.frame)-kbSize.width)) case UIInterfaceOrientation.LandscapeRight: - move = min(CGRectGetWidth(window.frame)-CGRectGetMaxX(textFieldViewRect)-(topLayoutGuide+5), _kbSize.width-CGRectGetMinX(textFieldViewRect)) + move = min(CGRectGetWidth(window.frame)-CGRectGetMaxX(textFieldViewRect)-(topLayoutGuide+5), kbSize.width-CGRectGetMinX(textFieldViewRect)) case UIInterfaceOrientation.Portrait: - move = min(CGRectGetMinY(textFieldViewRect)-(topLayoutGuide+5), CGRectGetMaxY(textFieldViewRect)-(CGRectGetHeight(window.frame)-_kbSize.height)) + move = min(CGRectGetMinY(textFieldViewRect)-(topLayoutGuide+5), CGRectGetMaxY(textFieldViewRect)-(CGRectGetHeight(window.frame)-kbSize.height)) case UIInterfaceOrientation.PortraitUpsideDown: - move = min(CGRectGetHeight(window.frame)-CGRectGetMaxY(textFieldViewRect)-(topLayoutGuide+5), _kbSize.height-CGRectGetMinY(textFieldViewRect)) + move = min(CGRectGetHeight(window.frame)-CGRectGetMaxY(textFieldViewRect)-(topLayoutGuide+5), kbSize.height-CGRectGetMinY(textFieldViewRect)) default: break } _IQShowLog("Need to move: \(move)") // Getting it's superScrollView. // (Enhancement ID: #21, #24) - let superScrollView : UIScrollView? = textFieldView.superviewOfClassType(UIScrollView) as? UIScrollView + let superScrollView = textFieldView.superviewOfClassType(UIScrollView) as? UIScrollView //If there was a lastScrollView. // (Bug ID: #34) if let lastScrollView = _lastScrollView { @@ -844,8 +886,7 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { _IQShowLog("Saving \(unwrappedSuperScrollView._IQDescription()) contentInset : \(_startingContentInsets) and contentOffset : \(_startingContentOffset)") } - - + // Special case for ScrollView. // If we found lastScrollView then setting it's contentOffset to show textField. if let lastScrollView = _lastScrollView { @@ -856,7 +897,7 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { while let scrollView = superScrollView { //Looping in upper hierarchy until we don't found any scrollView in it's upper hirarchy till UIWindow object. - if move > 0 ? move > -scrollView.contentOffset.y - scrollView.contentInset.top : scrollView.contentOffset.y>0 { + if move > 0 ? (move > (-scrollView.contentOffset.y - scrollView.contentInset.top)) : scrollView.contentOffset.y>0 { //Getting lastViewRect. if let lastViewRect = lastView.superview?.convertRect(lastView.frame, toView: scrollView) { @@ -867,11 +908,11 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { //Rearranging the expected Y offset according to the view. shouldOffsetY = min(shouldOffsetY, lastViewRect.origin.y /*-5*/) //-5 is for good UI.//Commenting -5 (Bug ID: #69) - + //[_textFieldView isKindOfClass:[UITextView class]] If is a UITextView type //[superScrollView superviewOfClassType:[UIScrollView class]] == nil If processing scrollView is last scrollView in upper hierarchy (there is no other scrollView upper hierrchy.) //[_textFieldView isKindOfClass:[UITextView class]] If is a UITextView type - //shouldOffsetY > 0 shouldOffsetY must be greater than in order to keep distance from navigationBar (Bug ID: #92) - if textFieldView is UITextView == true && scrollView.superviewOfClassType(UIScrollView) == nil && shouldOffsetY > 0 { + //shouldOffsetY >= 0 shouldOffsetY must be greater than in order to keep distance from navigationBar (Bug ID: #92) + if textFieldView is UITextView == true && scrollView.superviewOfClassType(UIScrollView) == nil && shouldOffsetY >= 0 { var maintainTopLayout : CGFloat = 0 if let navigationBarFrame = textFieldView.viewController()?.navigationController?.navigationBar.frame { @@ -914,8 +955,6 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { move -= (shouldOffsetY-scrollView.contentOffset.y) } - - //Getting problem while using `setContentOffset:animated:`, So I used animation API. UIView.animateWithDuration(_animationDuration, delay: 0, options: UIViewAnimationOptions.BeginFromCurrentState|_animationCurve, animations: { () -> Void in @@ -934,7 +973,6 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { break } } - //Updating contentInset if let lastScrollViewRect = lastScrollView.superview?.convertRect(lastScrollView.frame, toView: window) { @@ -943,13 +981,13 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { switch interfaceOrientation { case UIInterfaceOrientation.LandscapeLeft: - bottom = _kbSize.width-(CGRectGetWidth(window.frame)-CGRectGetMaxX(lastScrollViewRect)) + bottom = kbSize.width-(CGRectGetWidth(window.frame)-CGRectGetMaxX(lastScrollViewRect)) case UIInterfaceOrientation.LandscapeRight: - bottom = _kbSize.width-CGRectGetMinX(lastScrollViewRect) + bottom = kbSize.width-CGRectGetMinX(lastScrollViewRect) case UIInterfaceOrientation.Portrait: - bottom = _kbSize.height-(CGRectGetHeight(window.frame)-CGRectGetMaxY(lastScrollViewRect)) + bottom = kbSize.height-(CGRectGetHeight(window.frame)-CGRectGetMaxY(lastScrollViewRect)) case UIInterfaceOrientation.PortraitUpsideDown: - bottom = _kbSize.height-CGRectGetMinY(lastScrollViewRect) + bottom = kbSize.height-CGRectGetMinY(lastScrollViewRect) default: break } @@ -982,20 +1020,19 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { } //Going ahead. No else if. - //Special case for UITextView(Readjusting the move variable when textView hight is too big to fit on screen) //_canAdjustTextView If we have permission to adjust the textView, then let's do it on behalf of user (Enhancement ID: #15) //_lastScrollView If not having inside any scrollView, (now contentInset manages the full screen textView. //[_textFieldView isKindOfClass:[UITextView class]] If is a UITextView type //_isTextFieldViewFrameChanged If frame is not change by library in past (Bug ID: #92) - if canAdjustTextView == true && _lastScrollView == nil && textFieldView is UITextView == true && _isTextFieldViewFrameChanged == false { + if canAdjustTextView == true && _lastScrollView == nil && textFieldView is UITextView == true && _keyboardManagerFlags.isTextFieldViewFrameChanged == false { var textViewHeight = CGRectGetHeight(textFieldView.frame) switch interfaceOrientation { case UIInterfaceOrientation.LandscapeLeft, UIInterfaceOrientation.LandscapeRight: - textViewHeight = min(textViewHeight, (CGRectGetWidth(window.frame)-_kbSize.width-(topLayoutGuide+5))) + textViewHeight = min(textViewHeight, (CGRectGetWidth(window.frame)-kbSize.width-(topLayoutGuide+5))) case UIInterfaceOrientation.Portrait, UIInterfaceOrientation.PortraitUpsideDown: - textViewHeight = min(textViewHeight, (CGRectGetHeight(window.frame)-_kbSize.height-(topLayoutGuide+5))) + textViewHeight = min(textViewHeight, (CGRectGetHeight(window.frame)-kbSize.height-(topLayoutGuide+5))) default: break } @@ -1006,125 +1043,176 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { var textFieldViewRect = textFieldView.frame textFieldViewRect.size.height = textViewHeight textFieldView.frame = textFieldViewRect - self._isTextFieldViewFrameChanged = true + self._keyboardManagerFlags.isTextFieldViewFrameChanged = true self._IQShowLog("\(textFieldView._IQDescription()) New Frame : \(textFieldView.frame)") }, completion: { (finished) -> Void in }) } + + var hasDoneTweakLayoutGuide = false - // Special case for iPad modalPresentationStyle. - if rootController.modalPresentationStyle == UIModalPresentationStyle.FormSheet || rootController.modalPresentationStyle == UIModalPresentationStyle.PageSheet { + if let viewController = textFieldView.viewController() { - _IQShowLog("Found Special case for Model Presentation Style: \(rootController.modalPresentationStyle)") - - // Positive or zero. - if move >= 0 { - // We should only manipulate y. - rootViewRect.origin.y -= move + if let constraint = viewController.IQLayoutGuideConstraint { - // From now prevent keyboard manager to slide up the rootView to more than keyboard height. (Bug ID: #93) - if preventShowingBottomBlankSpace == true { - var minimumY: CGFloat = 0 + var layoutGuide : UILayoutSupport? + if let itemLayoutGuide = constraint.firstItem as? UILayoutSupport { + layoutGuide = itemLayoutGuide + } else if let itemLayoutGuide = constraint.secondItem as? UILayoutSupport { + layoutGuide = itemLayoutGuide + } + + if let itemLayoutGuide : UILayoutSupport = layoutGuide { - switch interfaceOrientation { - case UIInterfaceOrientation.LandscapeLeft, UIInterfaceOrientation.LandscapeRight: - minimumY = CGRectGetWidth(window.frame)-rootViewRect.size.height-topLayoutGuide-(_kbSize.width-keyboardDistanceFromTextField) - case UIInterfaceOrientation.Portrait, UIInterfaceOrientation.PortraitUpsideDown: - minimumY = (CGRectGetHeight(window.frame)-rootViewRect.size.height-topLayoutGuide)/2-(_kbSize.height-keyboardDistanceFromTextField) - default: break + if (itemLayoutGuide === viewController.topLayoutGuide) //If topLayoutGuide constraint + { + let constant = min(_layoutGuideConstraintInitialConstant, constraint.constant-move); + + UIView.animateWithDuration(_animationDuration, delay: 0, options: (_animationCurve|UIViewAnimationOptions.BeginFromCurrentState), animations: { () -> Void in + + constraint.constant = constant; + self._rootViewController?.view.setNeedsLayout() + self._rootViewController?.view.layoutIfNeeded() + + }, completion: { (finished) -> Void in }) + + hasDoneTweakLayoutGuide = true } - - rootViewRect.origin.y = max(CGRectGetMinY(rootViewRect), minimumY) - } - - _IQShowLog("Moving Upward") - // Setting adjusted rootViewRect - setRootViewFrame(rootViewRect) - } else { // Negative - // Calculating disturbed distance. Pull Request #3 - let disturbDistance = CGRectGetMinY(rootViewRect)-CGRectGetMinY(_topViewBeginRect) - - // disturbDistance Negative = frame disturbed. - // disturbDistance positive = frame not disturbed. - if disturbDistance < 0 { - // We should only manipulate y. - rootViewRect.origin.y -= max(move, disturbDistance) + else if (itemLayoutGuide === viewController.bottomLayoutGuide) //If bottomLayoutGuice constraint + { + let constant = max(_layoutGuideConstraintInitialConstant, constraint.constant+move); + + UIView.animateWithDuration(_animationDuration, delay: 0, options: (_animationCurve|UIViewAnimationOptions.BeginFromCurrentState), animations: { () -> Void in + + constraint.constant = constant; + self._rootViewController?.view.setNeedsLayout() + self._rootViewController?.view.layoutIfNeeded() + + }, completion: { (finished) -> Void in }) - _IQShowLog("Moving Downward") - // Setting adjusted rootViewRect - setRootViewFrame(rootViewRect) - } - } - } else { //If presentation style is neither UIModalPresentationFormSheet nor UIModalPresentationPageSheet then going ahead.(General case) - // Positive or zero. - if move >= 0 { - - switch interfaceOrientation { - case UIInterfaceOrientation.LandscapeLeft: rootViewRect.origin.x -= move - case UIInterfaceOrientation.LandscapeRight: rootViewRect.origin.x += move - case UIInterfaceOrientation.Portrait: rootViewRect.origin.y -= move - case UIInterfaceOrientation.PortraitUpsideDown: rootViewRect.origin.y += move - default: break - } - - // From now prevent keyboard manager to slide up the rootView to more than keyboard height. (Bug ID: #93) - if preventShowingBottomBlankSpace == true { - - switch interfaceOrientation { - case UIInterfaceOrientation.LandscapeLeft: - rootViewRect.origin.x = max(rootViewRect.origin.x, min(0, -_kbSize.width+keyboardDistanceFromTextField)) - case UIInterfaceOrientation.LandscapeRight: - rootViewRect.origin.x = min(rootViewRect.origin.x, +_kbSize.width-keyboardDistanceFromTextField) - case UIInterfaceOrientation.Portrait: - rootViewRect.origin.y = max(rootViewRect.origin.y, min(0, -_kbSize.height+keyboardDistanceFromTextField)) - case UIInterfaceOrientation.PortraitUpsideDown: - rootViewRect.origin.y = min(rootViewRect.origin.y, +_kbSize.height-keyboardDistanceFromTextField) - default: break + hasDoneTweakLayoutGuide = true } } - - _IQShowLog("Moving Upward") - // Setting adjusted rootViewRect - setRootViewFrame(rootViewRect) - } else { // Negative - var disturbDistance : CGFloat = 0 - - switch interfaceOrientation { - case UIInterfaceOrientation.LandscapeLeft: - disturbDistance = CGRectGetMinX(rootViewRect)-CGRectGetMinX(_topViewBeginRect) - case UIInterfaceOrientation.LandscapeRight: - disturbDistance = CGRectGetMinX(_topViewBeginRect)-CGRectGetMinX(rootViewRect) - case UIInterfaceOrientation.Portrait: - disturbDistance = CGRectGetMinY(rootViewRect)-CGRectGetMinY(_topViewBeginRect) - case UIInterfaceOrientation.PortraitUpsideDown: - disturbDistance = CGRectGetMinY(_topViewBeginRect)-CGRectGetMinY(rootViewRect) - default: break - } - - // disturbDistance Negative = frame disturbed. - // disturbDistance positive = frame not disturbed. - if disturbDistance < 0 { - - switch interfaceOrientation { - case UIInterfaceOrientation.LandscapeLeft: rootViewRect.origin.x -= max(move, disturbDistance) - case UIInterfaceOrientation.LandscapeRight: rootViewRect.origin.x += max(move, disturbDistance) - case UIInterfaceOrientation.Portrait: rootViewRect.origin.y -= max(move, disturbDistance) - case UIInterfaceOrientation.PortraitUpsideDown: rootViewRect.origin.y += max(move, disturbDistance) - default: break - } - - _IQShowLog("Moving Downward") - // Setting adjusted rootViewRect - // Setting adjusted rootViewRect - setRootViewFrame(rootViewRect) - } } } + + //If not constraint + if hasDoneTweakLayoutGuide == false { + + // Special case for iPad modalPresentationStyle. + if rootController.modalPresentationStyle == UIModalPresentationStyle.FormSheet || rootController.modalPresentationStyle == UIModalPresentationStyle.PageSheet { + + _IQShowLog("Found Special case for Model Presentation Style: \(rootController.modalPresentationStyle)") + + // +Positive or zero. + if move >= 0 { + // We should only manipulate y. + rootViewRect.origin.y -= move + + // From now prevent keyboard manager to slide up the rootView to more than keyboard height. (Bug ID: #93) + if preventShowingBottomBlankSpace == true { + var minimumY: CGFloat = 0 + + switch interfaceOrientation { + case UIInterfaceOrientation.LandscapeLeft, UIInterfaceOrientation.LandscapeRight: + minimumY = CGRectGetWidth(window.frame)-rootViewRect.size.height-topLayoutGuide-(kbSize.width-newKeyboardDistanceFromTextField) + case UIInterfaceOrientation.Portrait, UIInterfaceOrientation.PortraitUpsideDown: + minimumY = (CGRectGetHeight(window.frame)-rootViewRect.size.height-topLayoutGuide)/2-(kbSize.height-newKeyboardDistanceFromTextField) + default: break + } + + rootViewRect.origin.y = max(CGRectGetMinY(rootViewRect), minimumY) + } + + _IQShowLog("Moving Upward") + // Setting adjusted rootViewRect + setRootViewFrame(rootViewRect) + } else { // -Negative + // Calculating disturbed distance. Pull Request #3 + let disturbDistance = CGRectGetMinY(rootViewRect)-CGRectGetMinY(_topViewBeginRect) + + // disturbDistance Negative = frame disturbed. + // disturbDistance positive = frame not disturbed. + if disturbDistance < 0 { + // We should only manipulate y. + rootViewRect.origin.y -= max(move, disturbDistance) + + _IQShowLog("Moving Downward") + // Setting adjusted rootViewRect + setRootViewFrame(rootViewRect) + } + } + } else { //If presentation style is neither UIModalPresentationFormSheet nor UIModalPresentationPageSheet then going ahead.(General case) + // +Positive or zero. + if move >= 0 { + + switch interfaceOrientation { + case UIInterfaceOrientation.LandscapeLeft: rootViewRect.origin.x -= move + case UIInterfaceOrientation.LandscapeRight: rootViewRect.origin.x += move + case UIInterfaceOrientation.Portrait: rootViewRect.origin.y -= move + case UIInterfaceOrientation.PortraitUpsideDown: rootViewRect.origin.y += move + default: break + } + + // From now prevent keyboard manager to slide up the rootView to more than keyboard height. (Bug ID: #93) + if preventShowingBottomBlankSpace == true { + + switch interfaceOrientation { + case UIInterfaceOrientation.LandscapeLeft: + rootViewRect.origin.x = max(rootViewRect.origin.x, min(0, -kbSize.width+newKeyboardDistanceFromTextField)) + case UIInterfaceOrientation.LandscapeRight: + rootViewRect.origin.x = min(rootViewRect.origin.x, +kbSize.width-newKeyboardDistanceFromTextField) + case UIInterfaceOrientation.Portrait: + rootViewRect.origin.y = max(rootViewRect.origin.y, min(0, -kbSize.height+newKeyboardDistanceFromTextField)) + case UIInterfaceOrientation.PortraitUpsideDown: + rootViewRect.origin.y = min(rootViewRect.origin.y, +kbSize.height-newKeyboardDistanceFromTextField) + default: break + } + } + + _IQShowLog("Moving Upward") + // Setting adjusted rootViewRect + setRootViewFrame(rootViewRect) + } else { // -Negative + var disturbDistance : CGFloat = 0 + + switch interfaceOrientation { + case UIInterfaceOrientation.LandscapeLeft: + disturbDistance = CGRectGetMinX(rootViewRect)-CGRectGetMinX(_topViewBeginRect) + case UIInterfaceOrientation.LandscapeRight: + disturbDistance = CGRectGetMinX(_topViewBeginRect)-CGRectGetMinX(rootViewRect) + case UIInterfaceOrientation.Portrait: + disturbDistance = CGRectGetMinY(rootViewRect)-CGRectGetMinY(_topViewBeginRect) + case UIInterfaceOrientation.PortraitUpsideDown: + disturbDistance = CGRectGetMinY(_topViewBeginRect)-CGRectGetMinY(rootViewRect) + default: break + } + + // disturbDistance Negative = frame disturbed. + // disturbDistance positive = frame not disturbed. + if disturbDistance < 0 { + + switch interfaceOrientation { + case UIInterfaceOrientation.LandscapeLeft: rootViewRect.origin.x -= max(move, disturbDistance) + case UIInterfaceOrientation.LandscapeRight: rootViewRect.origin.x += max(move, disturbDistance) + case UIInterfaceOrientation.Portrait: rootViewRect.origin.y -= max(move, disturbDistance) + case UIInterfaceOrientation.PortraitUpsideDown: rootViewRect.origin.y += max(move, disturbDistance) + default: break + } + + _IQShowLog("Moving Downward") + // Setting adjusted rootViewRect + // Setting adjusted rootViewRect + setRootViewFrame(rootViewRect) + } + } + } + } + _IQShowLog("****** \(__FUNCTION__) ended ******") } - ///------------------------------- /// MARK: UIKeyboard Notifications ///------------------------------- @@ -1142,7 +1230,7 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { //Due to orientation callback we need to resave it's original frame. // (Bug ID: #46) //Added _isTextFieldViewFrameChanged check. Saving textFieldView current frame to use it with canAdjustTextView if textViewFrame has already not been changed. (Bug ID: #92) - if _isTextFieldViewFrameChanged == false { + if _keyboardManagerFlags.isTextFieldViewFrameChanged == false && _textFieldView != nil { if let textFieldView = _textFieldView { _textFieldViewIntialFrame = textFieldView.frame _IQShowLog("Saving \(textFieldView._IQDescription()) Initial frame : \(_textFieldViewIntialFrame)") @@ -1203,23 +1291,6 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { topMostController = keyWindow()?.topMostController() } - if let topController = topMostController { - //If it's iOS8 then we should do calculations according to portrait orientations. // (Bug ID: #64, #66) - let interfaceOrientation = (IQ_IS_IOS8_OR_GREATER) ? UIInterfaceOrientation.Portrait : topController.interfaceOrientation - - let _keyboardDistanceFromTextField = keyboardDistanceFromTextField - // let _keyboardDistanceFromTextField = (_textFieldView.keyboardDistanceFromTextField == kIQUseDefaultKeyboardDistance)?_keyboardDistanceFromTextField:_textFieldView.keyboardDistanceFromTextField - - // Adding Keyboard distance from textField. - switch interfaceOrientation { - case UIInterfaceOrientation.LandscapeLeft, UIInterfaceOrientation.LandscapeRight: - _kbSize.width += _keyboardDistanceFromTextField - case UIInterfaceOrientation.Portrait, UIInterfaceOrientation.PortraitUpsideDown: - _kbSize.height += _keyboardDistanceFromTextField - default: break - } - } - //If last restored keyboard size is different(any orientation accure), then refresh. otherwise not. if CGSizeEqualToSize(_kbSize, oldKBSize) == false { @@ -1273,7 +1344,7 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { // if (_textFieldView == nil) return // Boolean to know keyboard is showing/hiding - _isKeyboardShowing = false + _keyboardManagerFlags.isKeyboardShowing = false let info : [NSObject : AnyObject]? = notification?.userInfo @@ -1301,9 +1372,9 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { // TODO: restore scrollView state // This is temporary solution. Have to implement the save and restore scrollView state - var superScrollView = self._lastScrollView?.superviewOfClassType(UIScrollView) as? UIScrollView + var superScrollView = lastScrollView - while let scrollView = superScrollView { + while let scrollView = superScrollView.superviewOfClassType(UIScrollView) as? UIScrollView { let contentSize = CGSizeMake(max(scrollView.contentSize.width, CGRectGetWidth(scrollView.frame)), max(scrollView.contentSize.height, CGRectGetHeight(scrollView.frame))) @@ -1315,7 +1386,7 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { self._IQShowLog("Restoring \(scrollView._IQDescription()) contentOffset to : \(self._startingContentOffset)") } - superScrollView = superScrollView?.superviewOfClassType(UIScrollView) as? UIScrollView + superScrollView = scrollView } }) { (finished) -> Void in } } @@ -1333,18 +1404,46 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { //Used UIViewAnimationOptionBeginFromCurrentState to minimize strange animations. UIView.animateWithDuration(_animationDuration, delay: 0, options: UIViewAnimationOptions.BeginFromCurrentState|_animationCurve, animations: { () -> Void in - self._IQShowLog("Restoring \(rootViewController._IQDescription()) frame to : \(self._topViewBeginRect)") + var hasDoneTweakLayoutGuide = false - // Setting it's new frame - rootViewController.view.frame = self._topViewBeginRect - - //Animating content if needed (Bug ID: #204) - if self.layoutIfNeededOnUpdate == true { - //Animating content (Bug ID: #160) - rootViewController.view.setNeedsLayout() - rootViewController.view.layoutIfNeeded() + if let viewController = self._textFieldView?.viewController() { + + if let constraint = viewController.IQLayoutGuideConstraint { + + var layoutGuide : UILayoutSupport? + if let itemLayoutGuide = constraint.firstItem as? UILayoutSupport { + layoutGuide = itemLayoutGuide + } else if let itemLayoutGuide = constraint.secondItem as? UILayoutSupport { + layoutGuide = itemLayoutGuide + } + + if let itemLayoutGuide : UILayoutSupport = layoutGuide { + + if (itemLayoutGuide === viewController.topLayoutGuide || itemLayoutGuide === viewController.bottomLayoutGuide) + { + constraint.constant = self._layoutGuideConstraintInitialConstant + rootViewController.view.setNeedsLayout() + rootViewController.view.layoutIfNeeded() + + hasDoneTweakLayoutGuide = true + } + } + } } + if hasDoneTweakLayoutGuide == false { + self._IQShowLog("Restoring \(rootViewController._IQDescription()) frame to : \(self._topViewBeginRect)") + + // Setting it's new frame + rootViewController.view.frame = self._topViewBeginRect + + //Animating content if needed (Bug ID: #204) + if self.layoutIfNeededOnUpdate == true { + //Animating content (Bug ID: #160) + rootViewController.view.setNeedsLayout() + rootViewController.view.layoutIfNeeded() + } + } }) { (finished) -> Void in } _rootViewController = nil @@ -1362,7 +1461,6 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { _IQShowLog("****** \(__FUNCTION__) ended ******") } - func keyboardDidHide(notification:NSNotification) { _IQShowLog("****** \(__FUNCTION__) started ******") @@ -1405,7 +1503,7 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { // Saving textFieldView current frame to use it with canAdjustTextView if textViewFrame has already not been changed. //Added _isTextFieldViewFrameChanged check. (Bug ID: #92) - if _isTextFieldViewFrameChanged == false { + if _keyboardManagerFlags.isTextFieldViewFrameChanged == false { if let textFieldView = _textFieldView { _textFieldViewIntialFrame = textFieldView.frame _IQShowLog("Saving \(textFieldView._IQDescription()) Initial frame : \(_textFieldViewIntialFrame)") @@ -1426,6 +1524,16 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { }, completion: { (finished) -> Void in + //RestoringTextView before reloading inputViews + if (self._keyboardManagerFlags.isTextFieldViewFrameChanged) + { + self._keyboardManagerFlags.isTextFieldViewFrameChanged = false; + + if let textFieldView = self._textFieldView { + textFieldView.frame = self._textFieldViewIntialFrame; + } + } + //On textView toolbar didn't appear on first time, so forcing textView to reload it's inputViews. self._textFieldView?.reloadInputViews() }) @@ -1442,9 +1550,13 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { _textFieldView?.window?.addGestureRecognizer(_tapGesture) // (Enhancement ID: #14) - if _isKeyboardShowing == false { // (Bug ID: #5) + if _keyboardManagerFlags.isKeyboardShowing == false { // (Bug ID: #5) // keyboard is not showing(At the beginning only). We should save rootViewRect. + if let constant = _textFieldView?.viewController()?.IQLayoutGuideConstraint?.constant { + _layoutGuideConstraintInitialConstant = constant + } + _rootViewController = _textFieldView?.topMostController() if _rootViewController == nil { _rootViewController = keyWindow()?.topMostController() @@ -1496,9 +1608,9 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { _textFieldView?.window?.removeGestureRecognizer(_tapGesture) // We check if there's a change in original frame or not. - if _isTextFieldViewFrameChanged == true { + if _keyboardManagerFlags.isTextFieldViewFrameChanged == true { UIView.animateWithDuration(_animationDuration, delay: 0, options: UIViewAnimationOptions.BeginFromCurrentState|_animationCurve, animations: { () -> Void in - self._isTextFieldViewFrameChanged = false + self._keyboardManagerFlags.isTextFieldViewFrameChanged = false self._IQShowLog("Restoring \(self._textFieldView?._IQDescription()) frame to : \(self._textFieldViewIntialFrame)") @@ -1518,7 +1630,7 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { if shouldFixTextViewClip { let textView = notification.object as! UITextView - let line = textView .caretRectForPosition(textView.selectedTextRange?.start) + let line = textView.caretRectForPosition(textView.selectedTextRange?.start) let overflow = CGRectGetMaxY(line) - (textView.contentOffset.y + CGRectGetHeight(textView.bounds) - textView.contentInset.bottom - textView.contentInset.top) @@ -1537,7 +1649,6 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { } } - ///------------------------------------------ /// MARK: Interface Orientation Notifications ///------------------------------------------ @@ -1548,11 +1659,11 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { _IQShowLog("****** \(__FUNCTION__) started ******") //If textFieldViewInitialRect is saved then restore it.(UITextView case @canAdjustTextView) - if _isTextFieldViewFrameChanged == true { + if _keyboardManagerFlags.isTextFieldViewFrameChanged == true { if let textFieldView = _textFieldView { //Due to orientation callback we need to set it's original position. UIView.animateWithDuration(_animationDuration, delay: 0, options: (_animationCurve|UIViewAnimationOptions.BeginFromCurrentState), animations: { () -> Void in - self._isTextFieldViewFrameChanged = false + self._keyboardManagerFlags.isTextFieldViewFrameChanged = false self._IQShowLog("Restoring \(textFieldView._IQDescription()) frame to : \(self._textFieldViewIntialFrame)") @@ -1566,7 +1677,6 @@ class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate { _IQShowLog("****** \(__FUNCTION__) ended ******") } - ///------------------ /// MARK: AutoToolbar ///------------------ diff --git a/IQKeybordManagerSwift/IQTextView/IQTextView.swift b/IQKeybordManagerSwift/IQTextView/IQTextView.swift index 66cc923..c18e17d 100644 --- a/IQKeybordManagerSwift/IQTextView/IQTextView.swift +++ b/IQKeybordManagerSwift/IQTextView/IQTextView.swift @@ -29,8 +29,23 @@ class IQTextView : UITextView { required init(coder aDecoder: NSCoder) { super.init(coder: aDecoder) + NSNotificationCenter.defaultCenter().addObserver(self, selector: "refreshPlaceholder", name: UITextViewTextDidChangeNotification, object: self) } + override init(frame: CGRect, textContainer: NSTextContainer?) { + super.init(frame: frame, textContainer: textContainer) + NSNotificationCenter.defaultCenter().addObserver(self, selector: "refreshPlaceholder", name: UITextViewTextDidChangeNotification, object: self) + } + + override func awakeFromNib() { + super.awakeFromNib() + NSNotificationCenter.defaultCenter().addObserver(self, selector: "refreshPlaceholder", name: UITextViewTextDidChangeNotification, object: self) + } + + deinit { + NSNotificationCenter.defaultCenter().removeObserver(self) + } + private var placeholderLabel: UILabel? /** @abstract To set textView's placeholder text. Default is ni. */ diff --git a/IQKeybordManagerSwift/IQToolbar/IQTitleBarButtonItem.swift b/IQKeybordManagerSwift/IQToolbar/IQTitleBarButtonItem.swift index 93ed897..9fd4009 100644 --- a/IQKeybordManagerSwift/IQToolbar/IQTitleBarButtonItem.swift +++ b/IQKeybordManagerSwift/IQToolbar/IQTitleBarButtonItem.swift @@ -30,15 +30,16 @@ class IQTitleBarButtonItem: UIBarButtonItem { didSet { if let unwrappedFont = font { - titleLabel?.font = unwrappedFont + _titleLabel?.font = unwrappedFont } else { - titleLabel?.font = UIFont.boldSystemFontOfSize(12) + _titleLabel?.font = UIFont.boldSystemFontOfSize(12) } } } - private var titleLabel : UILabel? - + private var _titleLabel : UILabel? + private var _titleView : UIView? + override init() { super.init() } @@ -47,14 +48,19 @@ class IQTitleBarButtonItem: UIBarButtonItem { super.init(title: nil, style: UIBarButtonItemStyle.Plain, target: nil, action: nil) - titleLabel = UILabel(frame: frame) - titleLabel?.backgroundColor = UIColor.clearColor() - titleLabel?.textAlignment = .Center - titleLabel?.text = title - titleLabel?.autoresizingMask = .FlexibleWidth + _titleView = UIView(frame: frame) + _titleView?.backgroundColor = UIColor.clearColor() + _titleView?.autoresizingMask = .FlexibleWidth + + _titleLabel = UILabel(frame: _titleView!.bounds) + _titleLabel?.textColor = UIColor.lightGrayColor() + _titleLabel?.backgroundColor = UIColor.clearColor() + _titleLabel?.textAlignment = .Center + _titleLabel?.text = title + _titleLabel?.autoresizingMask = .FlexibleWidth font = UIFont.boldSystemFontOfSize(12.0) - titleLabel?.font = self.font - customView = titleLabel + _titleLabel?.font = self.font + customView = _titleLabel enabled = false } diff --git a/IQKeybordManagerSwift/IQToolbar/IQToolbar.swift b/IQKeybordManagerSwift/IQToolbar/IQToolbar.swift index f601647..a65e3aa 100644 --- a/IQKeybordManagerSwift/IQToolbar/IQToolbar.swift +++ b/IQKeybordManagerSwift/IQToolbar/IQToolbar.swift @@ -27,6 +27,14 @@ import UIKit /** @abstract IQToolbar for IQKeyboardManager. */ class IQToolbar: UIToolbar , UIInputViewAudioFeedback { + override class func initialize() { + + superclass()?.initialize() + + self.appearance().barTintColor = nil + self.appearance().backgroundColor = nil + } + var titleFont : UIFont? { didSet { @@ -62,7 +70,6 @@ class IQToolbar: UIToolbar , UIInputViewAudioFeedback { sizeToFit() autoresizingMask = UIViewAutoresizing.FlexibleWidth - tintColor = UIColor .blackColor() } @@ -71,7 +78,6 @@ class IQToolbar: UIToolbar , UIInputViewAudioFeedback { sizeToFit() autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight - tintColor = UIColor .blackColor() } @@ -84,11 +90,11 @@ class IQToolbar: UIToolbar , UIInputViewAudioFeedback { override var tintColor: UIColor! { didSet { - if items != nil { - for item in items as! [UIBarButtonItem] { + if let unwrappedItems = items { + for item in unwrappedItems as! [UIBarButtonItem] { if item is IQTitleBarButtonItem { - (item as! IQTitleBarButtonItem).tintColor = tintColor + item.tintColor = tintColor } } } diff --git a/IQKeybordManagerSwift/IQToolbar/IQUIView+IQKeyboardToolbar.swift b/IQKeybordManagerSwift/IQToolbar/IQUIView+IQKeyboardToolbar.swift index be68ebf..013be18 100644 --- a/IQKeybordManagerSwift/IQToolbar/IQUIView+IQKeyboardToolbar.swift +++ b/IQKeybordManagerSwift/IQToolbar/IQUIView+IQKeyboardToolbar.swift @@ -25,6 +25,8 @@ import Foundation import UIKit +private var kIQShouldHideTitle = "kIQShouldHideTitle" + /** UIView category methods to add IQToolbar on UIKeyboard. */ @@ -39,7 +41,7 @@ extension UIView { */ var shouldHideTitle: Bool? { get { - let aValue: AnyObject? = objc_getAssociatedObject(self, "shouldHideTitle") + let aValue: AnyObject? = objc_getAssociatedObject(self, &kIQShouldHideTitle) if aValue == nil { return false @@ -48,7 +50,7 @@ extension UIView { } } set(newValue) { - objc_setAssociatedObject(self, "shouldHideTitle", newValue, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC)) + objc_setAssociatedObject(self, &kIQShouldHideTitle, newValue, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC)) } } @@ -452,7 +454,7 @@ extension UIView { var items : [UIBarButtonItem] = [] // Create a cancel button to show on keyboard to resign it. Adding a selector to resign it. - let cancelButton = IQBarButtonItem(title: leftButtonTitle, style: UIBarButtonItemStyle.Bordered, target: target, action: leftButtonAction) + let cancelButton = IQBarButtonItem(title: leftButtonTitle, style: UIBarButtonItemStyle.Plain, target: target, action: leftButtonAction) items.append(cancelButton) if let unwrappedTitleText = titleText { @@ -474,7 +476,7 @@ extension UIView { items.append(nilButton) // Create a done button to show on keyboard to resign it. Adding a selector to resign it. - let doneButton = IQBarButtonItem(title: rightButtonTitle, style: UIBarButtonItemStyle.Bordered, target: target, action: rightButtonAction) + let doneButton = IQBarButtonItem(title: rightButtonTitle, style: UIBarButtonItemStyle.Plain, target: target, action: rightButtonAction) items.append(doneButton) // Adding button to toolBar. @@ -686,7 +688,7 @@ extension UIView { var items : [UIBarButtonItem] = [] // Create a done button to show on keyboard to resign it. Adding a selector to resign it. - let doneButton = IQBarButtonItem(title: rightButtonTitle, style: UIBarButtonItemStyle.Bordered, target: target, action: rightButtonAction) + let doneButton = IQBarButtonItem(title: rightButtonTitle, style: UIBarButtonItemStyle.Plain, target: target, action: rightButtonAction) let prev = IQBarButtonItem(image: UIImage(named: "IQKeyboardManager.bundle/IQButtonBarArrowLeft"), style: UIBarButtonItemStyle.Plain, target: target, action: previousAction) diff --git a/KeyboardTextFieldDemo/IQKeyboardManager Swift/Base.lproj/LaunchScreen.xib b/KeyboardTextFieldDemo/IQKeyboardManager Swift/Base.lproj/LaunchScreen.xib deleted file mode 100644 index 26792bb..0000000 --- a/KeyboardTextFieldDemo/IQKeyboardManager Swift/Base.lproj/LaunchScreen.xib +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/KeyboardTextFieldDemo/IQKeyboardManager Swift/Info.plist b/KeyboardTextFieldDemo/IQKeyboardManager Swift/Info.plist index 0edaa90..440ca49 100644 --- a/KeyboardTextFieldDemo/IQKeyboardManager Swift/Info.plist +++ b/KeyboardTextFieldDemo/IQKeyboardManager Swift/Info.plist @@ -22,8 +22,6 @@ 1 LSRequiresIPhoneOS - UILaunchStoryboardName - LaunchScreen UIMainStoryboardFile MainSwift UIRequiredDeviceCapabilities diff --git a/KeyboardTextFieldDemo/IQKeyboardManager Swift/Swift Pending.rtf b/KeyboardTextFieldDemo/IQKeyboardManager Swift/Swift Pending.rtf index 0b19c6a..bc78a7a 100644 --- a/KeyboardTextFieldDemo/IQKeyboardManager Swift/Swift Pending.rtf +++ b/KeyboardTextFieldDemo/IQKeyboardManager Swift/Swift Pending.rtf @@ -1,18 +1,14 @@ -{\rtf1\ansi\ansicpg1252\cocoartf1343\cocoasubrtf140 -{\fonttbl\f0\fswiss\fcharset0 Helvetica;} +{\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570 +{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 Menlo-Regular;} {\colortbl;\red255\green255\blue255;} -{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{decimal\}.}{\leveltext\leveltemplateid1\'02\'00.;}{\levelnumbers\'01;}\fi-360\li720\lin720 }{\listname ;}\listid1} -{\list\listtemplateid2\listhybrid{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{decimal\}.}{\leveltext\leveltemplateid101\'02\'00.;}{\levelnumbers\'01;}\fi-360\li720\lin720 }{\listname ;}\listid2}} -{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}{\listoverride\listid2\listoverridecount0\ls2}} \margl1440\margr1440\vieww9000\viewh8400\viewkind0 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural -\f0\b\fs24 \cf0 \ -\pard\tx220\tx720\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\li720\fi-720\pardirnatural -\ls1\ilvl0\cf0 {\listtext 1. }Need to Convert NSMutableSet to swift Array\ -\pard\tx220\tx720\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\li720\fi-720\pardirnatural -\ls2\ilvl0\cf0 {\listtext 2. }Need to convert NSArray to swift Array\ -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural -\cf0 \ -\ +\f0\fs24 \cf0 \ + 1. Need to Convert NSMutableSet to swift Array\ + 2. Need to convert NSArray to swift Array\ + 3. +\f1\fs26 setCustomDoneTarget on IQUIView+IQKeyboardToolbar.swift\ + 4. Need to match IQUIView+IQKeyboardToolbar.swift with Objective-C Version\ + 5. Debug Hierarchy on IQUIView+Hierarchy.swift\ } \ No newline at end of file diff --git a/KeyboardTextFieldDemo/IQKeyboardManager.xcodeproj/project.pbxproj b/KeyboardTextFieldDemo/IQKeyboardManager.xcodeproj/project.pbxproj index 84bfd0e..5074eaf 100755 --- a/KeyboardTextFieldDemo/IQKeyboardManager.xcodeproj/project.pbxproj +++ b/KeyboardTextFieldDemo/IQKeyboardManager.xcodeproj/project.pbxproj @@ -93,7 +93,6 @@ C0A392161B208F8300783FDD /* IQUIViewController+Additions.m in Sources */ = {isa = PBXBuildFile; fileRef = C0A392141B208F8300783FDD /* IQUIViewController+Additions.m */; }; C0AB9307195F57BB00447049 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9DC4CE2E18DAF77300DB2CB0 /* Main.storyboard */; }; C0ACB10119CF104E0057B571 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C0ACB10019CF104E0057B571 /* Images.xcassets */; }; - C0ACB10419CF104F0057B571 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = C0ACB10219CF104F0057B571 /* LaunchScreen.xib */; }; C0B63BA01781FAB1008D3B64 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0B63B9F1781FAB1008D3B64 /* UIKit.framework */; }; C0B63BA21781FAB1008D3B64 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0B63BA11781FAB1008D3B64 /* Foundation.framework */; }; C0B63BA41781FAB1008D3B64 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0B63BA31781FAB1008D3B64 /* CoreGraphics.framework */; }; @@ -112,6 +111,8 @@ C0DDEB6C19FCD56300FAB29F /* IQToolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DDEB5D19FCD56300FAB29F /* IQToolbar.swift */; }; C0DDEB6D19FCD56300FAB29F /* IQUIView+IQKeyboardToolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DDEB5E19FCD56300FAB29F /* IQUIView+IQKeyboardToolbar.swift */; }; C0DDEB6E19FCD56300FAB29F /* IQKeyboardManager.bundle in Resources */ = {isa = PBXBuildFile; fileRef = C0DDEB6019FCD56300FAB29F /* IQKeyboardManager.bundle */; }; + C0E9FD191B7E01F400C62579 /* IQUITextFieldView+Additions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0E9FD171B7E01E500C62579 /* IQUITextFieldView+Additions.swift */; }; + C0E9FD1C1B7E021000C62579 /* IQUIViewController+Additions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0E9FD1A1B7E020E00C62579 /* IQUIViewController+Additions.swift */; }; C0EC59D219D0C0B100997FFE /* TextFieldViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0EC59D119D0C0B100997FFE /* TextFieldViewController.swift */; }; C0EC59D419D0C0C600997FFE /* ScrollViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0EC59D319D0C0C600997FFE /* ScrollViewController.swift */; }; C0EC59D619D0C0D200997FFE /* WebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0EC59D519D0C0D200997FFE /* WebViewController.swift */; }; @@ -217,16 +218,15 @@ C08A654C19DB18C700D255E2 /* ManualToolbarViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ManualToolbarViewController.m; sourceTree = ""; }; C08B91B719D7558800AF16E7 /* TextSelectionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextSelectionViewController.h; sourceTree = ""; }; C08B91B819D7558800AF16E7 /* TextSelectionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TextSelectionViewController.m; sourceTree = ""; }; - C08CE0BC1A5C5EAC00FD9273 /* Swift Pending.rtf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.rtf; name = "Swift Pending.rtf"; path = "IQKeyboardManager Swift/Swift Pending.rtf"; sourceTree = ""; }; + C08CE0BC1A5C5EAC00FD9273 /* Swift Pending.rtf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.rtf; name = "Swift Pending.rtf"; path = "../IQKeyboardManager Swift/Swift Pending.rtf"; sourceTree = ""; }; C09576A719D811E00081DEB9 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; C0A392111B208F8300783FDD /* IQUITextFieldView+Additions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "IQUITextFieldView+Additions.h"; sourceTree = ""; }; C0A392121B208F8300783FDD /* IQUITextFieldView+Additions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "IQUITextFieldView+Additions.m"; sourceTree = ""; }; C0A392131B208F8300783FDD /* IQUIViewController+Additions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "IQUIViewController+Additions.h"; sourceTree = ""; }; C0A392141B208F8300783FDD /* IQUIViewController+Additions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "IQUIViewController+Additions.m"; sourceTree = ""; }; C0ACB0F519CF104B0057B571 /* IQKeyboardManager Swift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "IQKeyboardManager Swift.app"; sourceTree = BUILT_PRODUCTS_DIR; }; - C0ACB0F819CF104D0057B571 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C0ACB0F819CF104D0057B571 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = "../IQKeyboardManager Swift/Info.plist"; sourceTree = ""; }; C0ACB10019CF104E0057B571 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = "../IQKeyboardManager Swift/Images.xcassets"; sourceTree = ""; }; - C0ACB10319CF104F0057B571 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; C0B63B9B1781FAB1008D3B64 /* IQKeyboardManager.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = IQKeyboardManager.app; sourceTree = BUILT_PRODUCTS_DIR; }; C0B63B9F1781FAB1008D3B64 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; C0B63BA11781FAB1008D3B64 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -238,7 +238,7 @@ C0B63BAF1781FAB1008D3B64 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; C0DDEB4E19FCD56300FAB29F /* IQNSArray+Sort.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "IQNSArray+Sort.swift"; sourceTree = ""; }; C0DDEB4F19FCD56300FAB29F /* IQUIView+Hierarchy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "IQUIView+Hierarchy.swift"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; - C0DDEB5019FCD56300FAB29F /* IQUIWindow+Hierarchy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "IQUIWindow+Hierarchy.swift"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; + C0DDEB5019FCD56300FAB29F /* IQUIWindow+Hierarchy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "IQUIWindow+Hierarchy.swift"; sourceTree = ""; }; C0DDEB5219FCD56300FAB29F /* IQKeyboardManagerConstants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IQKeyboardManagerConstants.swift; sourceTree = ""; }; C0DDEB5319FCD56300FAB29F /* IQKeyboardManagerConstantsInternal.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IQKeyboardManagerConstantsInternal.swift; sourceTree = ""; }; C0DDEB5419FCD56300FAB29F /* IQKeyboardManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = IQKeyboardManager.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; @@ -247,8 +247,10 @@ C0DDEB5B19FCD56300FAB29F /* IQBarButtonItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IQBarButtonItem.swift; sourceTree = ""; }; C0DDEB5C19FCD56300FAB29F /* IQTitleBarButtonItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IQTitleBarButtonItem.swift; sourceTree = ""; }; C0DDEB5D19FCD56300FAB29F /* IQToolbar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IQToolbar.swift; sourceTree = ""; }; - C0DDEB5E19FCD56300FAB29F /* IQUIView+IQKeyboardToolbar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "IQUIView+IQKeyboardToolbar.swift"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; + C0DDEB5E19FCD56300FAB29F /* IQUIView+IQKeyboardToolbar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "IQUIView+IQKeyboardToolbar.swift"; sourceTree = ""; }; C0DDEB6019FCD56300FAB29F /* IQKeyboardManager.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = IQKeyboardManager.bundle; sourceTree = ""; }; + C0E9FD171B7E01E500C62579 /* IQUITextFieldView+Additions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "IQUITextFieldView+Additions.swift"; sourceTree = ""; }; + C0E9FD1A1B7E020E00C62579 /* IQUIViewController+Additions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "IQUIViewController+Additions.swift"; sourceTree = ""; }; C0EC59D119D0C0B100997FFE /* TextFieldViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TextFieldViewController.swift; path = "IQKeyboardManager Swift/TextFieldViewController.swift"; sourceTree = ""; }; C0EC59D319D0C0C600997FFE /* ScrollViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ScrollViewController.swift; path = "IQKeyboardManager Swift/ScrollViewController.swift"; sourceTree = ""; }; C0EC59D519D0C0D200997FFE /* WebViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WebViewController.swift; path = "IQKeyboardManager Swift/WebViewController.swift"; sourceTree = ""; }; @@ -457,17 +459,6 @@ path = Resources; sourceTree = ""; }; - C08549D519FAA92E00973573 /* Swift Demo */ = { - isa = PBXGroup; - children = ( - C08CE0BC1A5C5EAC00FD9273 /* Swift Pending.rtf */, - C0DDEB4C19FCD56300FAB29F /* IQKeybordManagerSwift */, - C0DD7E9F19D0A0AE007604CF /* KeyboardTextFieldDemoSwift */, - C0ACB0F619CF104C0057B571 /* IQKeyboardManager Swift */, - ); - name = "Swift Demo"; - sourceTree = ""; - }; C0A25BD219D72AAA009E074D /* TableViewController Example */ = { isa = PBXGroup; children = ( @@ -477,27 +468,10 @@ name = "TableViewController Example"; sourceTree = ""; }; - C0ACB0F619CF104C0057B571 /* IQKeyboardManager Swift */ = { - isa = PBXGroup; - children = ( - C0ACB10219CF104F0057B571 /* LaunchScreen.xib */, - C0ACB0F719CF104D0057B571 /* Supporting Files */, - ); - path = "IQKeyboardManager Swift"; - sourceTree = ""; - }; - C0ACB0F719CF104D0057B571 /* Supporting Files */ = { - isa = PBXGroup; - children = ( - C0ACB0F819CF104D0057B571 /* Info.plist */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; C0B63B901781FAB0008D3B64 = { isa = PBXGroup; children = ( - C08549D519FAA92E00973573 /* Swift Demo */, + C0DDEB4C19FCD56300FAB29F /* IQKeybordManagerSwift */, C085498E19FAA91E00973573 /* IQKeyBoardManager */, C0B63BA51781FAB1008D3B64 /* KeyboardTextFieldDemo */, C0DE7A3019D49D3400B6A582 /* Resources */, @@ -535,41 +509,9 @@ C0B63BA51781FAB1008D3B64 /* KeyboardTextFieldDemo */ = { isa = PBXGroup; children = ( - C05DD9FC1A591D2D00A6ECD4 /* IQDropDownTextField */, - C0ACB10019CF104E0057B571 /* Images.xcassets */, - C07E20C0185900BD001699A8 /* TextFieldViewController.h */, - C07E20C1185900BD001699A8 /* TextFieldViewController.m */, - C00EAA6B1858D5A500968DE2 /* ScrollViewController.h */, - C07E20B41858FF54001699A8 /* ScrollViewController.m */, - C07E20B918590085001699A8 /* WebViewController.h */, - C07E20BA18590085001699A8 /* WebViewController.m */, - C080A59018740EFF0088441B /* TextViewSpecialCaseViewController.h */, - C080A59118740EFF0088441B /* TextViewSpecialCaseViewController.m */, - 53CF2B7D1903D02200E3FDEA /* NavigationBarViewController.h */, - 53CF2B7E1903D02200E3FDEA /* NavigationBarViewController.m */, - 9D03F06D18BDC19400F4970D /* SpecialCaseViewController.h */, - 9D03F06E18BDC19400F4970D /* SpecialCaseViewController.m */, - 9D8E5DAA18BC8E1D005695CF /* ViewController.h */, - 9D8E5DAB18BC8E1D005695CF /* ViewController.m */, - C08B91B719D7558800AF16E7 /* TextSelectionViewController.h */, - C08B91B819D7558800AF16E7 /* TextSelectionViewController.m */, - C08A654B19DB18C700D255E2 /* ManualToolbarViewController.h */, - C08A654C19DB18C700D255E2 /* ManualToolbarViewController.m */, - C0F1193819EEDCD500708D17 /* BottomBlankSpaceViewController.h */, - C0F1193919EEDCD500708D17 /* BottomBlankSpaceViewController.m */, - C02790321A01404000FCB517 /* CollectionViewDemoController.h */, - C02790331A01404000FCB517 /* CollectionViewDemoController.m */, - DDAA29F01A320057002C0ED8 /* TableViewInContainerViewController.h */, - DDAA29F11A320057002C0ED8 /* TableViewInContainerViewController.m */, - 1C2270101AE69224003A9D15 /* CustomViewController.h */, - 1C2270111AE69224003A9D15 /* CustomViewController.m */, - 1C22700D1AE68EEE003A9D15 /* CustomSubclassView.h */, - 1C22700E1AE68EEE003A9D15 /* CustomSubclassView.m */, - C0A25BD219D72AAA009E074D /* TableViewController Example */, - C06579C119D60AAF00DAA3EA /* Settings */, + C0E9FD161B7DEEE800C62579 /* Swift */, + C0E9FD151B7DEEC900C62579 /* Objective-C */, 9DC4CE2E18DAF77300DB2CB0 /* Main.storyboard */, - C0B63BAE1781FAB1008D3B64 /* AppDelegate.h */, - C0B63BAF1781FAB1008D3B64 /* AppDelegate.m */, C0B63BA61781FAB1008D3B64 /* Supporting Files */, ); path = KeyboardTextFieldDemo; @@ -612,6 +554,7 @@ 1C1ADFC71AE51F74007A73E3 /* Settings */, ); name = KeyboardTextFieldDemoSwift; + path = ..; sourceTree = ""; }; C0DDEB4C19FCD56300FAB29F /* IQKeybordManagerSwift */ = { @@ -633,7 +576,9 @@ isa = PBXGroup; children = ( C0DDEB4E19FCD56300FAB29F /* IQNSArray+Sort.swift */, + C0E9FD171B7E01E500C62579 /* IQUITextFieldView+Additions.swift */, C0DDEB4F19FCD56300FAB29F /* IQUIView+Hierarchy.swift */, + C0E9FD1A1B7E020E00C62579 /* IQUIViewController+Additions.swift */, C0DDEB5019FCD56300FAB29F /* IQUIWindow+Hierarchy.swift */, ); path = Categories; @@ -683,6 +628,57 @@ name = Resources; sourceTree = ""; }; + C0E9FD151B7DEEC900C62579 /* Objective-C */ = { + isa = PBXGroup; + children = ( + C05DD9FC1A591D2D00A6ECD4 /* IQDropDownTextField */, + C0ACB10019CF104E0057B571 /* Images.xcassets */, + C07E20C0185900BD001699A8 /* TextFieldViewController.h */, + C07E20C1185900BD001699A8 /* TextFieldViewController.m */, + C00EAA6B1858D5A500968DE2 /* ScrollViewController.h */, + C07E20B41858FF54001699A8 /* ScrollViewController.m */, + C07E20B918590085001699A8 /* WebViewController.h */, + C07E20BA18590085001699A8 /* WebViewController.m */, + C080A59018740EFF0088441B /* TextViewSpecialCaseViewController.h */, + C080A59118740EFF0088441B /* TextViewSpecialCaseViewController.m */, + 53CF2B7D1903D02200E3FDEA /* NavigationBarViewController.h */, + 53CF2B7E1903D02200E3FDEA /* NavigationBarViewController.m */, + 9D03F06D18BDC19400F4970D /* SpecialCaseViewController.h */, + 9D03F06E18BDC19400F4970D /* SpecialCaseViewController.m */, + 9D8E5DAA18BC8E1D005695CF /* ViewController.h */, + 9D8E5DAB18BC8E1D005695CF /* ViewController.m */, + C08B91B719D7558800AF16E7 /* TextSelectionViewController.h */, + C08B91B819D7558800AF16E7 /* TextSelectionViewController.m */, + C08A654B19DB18C700D255E2 /* ManualToolbarViewController.h */, + C08A654C19DB18C700D255E2 /* ManualToolbarViewController.m */, + C0F1193819EEDCD500708D17 /* BottomBlankSpaceViewController.h */, + C0F1193919EEDCD500708D17 /* BottomBlankSpaceViewController.m */, + C02790321A01404000FCB517 /* CollectionViewDemoController.h */, + C02790331A01404000FCB517 /* CollectionViewDemoController.m */, + DDAA29F01A320057002C0ED8 /* TableViewInContainerViewController.h */, + DDAA29F11A320057002C0ED8 /* TableViewInContainerViewController.m */, + 1C2270101AE69224003A9D15 /* CustomViewController.h */, + 1C2270111AE69224003A9D15 /* CustomViewController.m */, + 1C22700D1AE68EEE003A9D15 /* CustomSubclassView.h */, + 1C22700E1AE68EEE003A9D15 /* CustomSubclassView.m */, + C0A25BD219D72AAA009E074D /* TableViewController Example */, + C06579C119D60AAF00DAA3EA /* Settings */, + C0B63BAE1781FAB1008D3B64 /* AppDelegate.h */, + C0B63BAF1781FAB1008D3B64 /* AppDelegate.m */, + ); + name = "Objective-C"; + sourceTree = ""; + }; + C0E9FD161B7DEEE800C62579 /* Swift */ = { + isa = PBXGroup; + children = ( + C08CE0BC1A5C5EAC00FD9273 /* Swift Pending.rtf */, + C0ACB0F819CF104D0057B571 /* Info.plist */, + C0DD7E9F19D0A0AE007604CF /* KeyboardTextFieldDemoSwift */, + ); + name = Swift; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -820,7 +816,6 @@ B53A8A301A4C2A3900951878 /* iTunesArtwork@2x in Resources */, C05C59411A4C7F110007BD8F /* IQKeyboardManagerScreenshot.png in Resources */, B53A8A331A4C2D7A00951878 /* icon.png in Resources */, - C0ACB10419CF104F0057B571 /* LaunchScreen.xib in Resources */, C0ACB10119CF104E0057B571 /* Images.xcassets in Resources */, C0EC59DE19D0C11200997FFE /* MainSwift.storyboard in Resources */, ); @@ -887,6 +882,7 @@ C0EC59D219D0C0B100997FFE /* TextFieldViewController.swift in Sources */, C056E1F41AE41B0100F09472 /* AppDelegate.swift in Sources */, 1C1ADFC31AE50E28007A73E3 /* CollectionViewDemoController.swift in Sources */, + C0E9FD1C1B7E021000C62579 /* IQUIViewController+Additions.swift in Sources */, C0EC59D619D0C0D200997FFE /* WebViewController.swift in Sources */, C0DDEB6919FCD56300FAB29F /* IQTextView.swift in Sources */, 1C1ADFC91AE51FB5007A73E3 /* ExampleTableViewController.swift in Sources */, @@ -909,6 +905,7 @@ C0DDEB6219FCD56300FAB29F /* IQUIView+Hierarchy.swift in Sources */, C0DDEB6519FCD56300FAB29F /* IQKeyboardManagerConstantsInternal.swift in Sources */, 1C1ADFBF1AE50D9B007A73E3 /* ManualToolbarViewController.swift in Sources */, + C0E9FD191B7E01F400C62579 /* IQUITextFieldView+Additions.swift in Sources */, C0DDEB6119FCD56300FAB29F /* IQNSArray+Sort.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -977,14 +974,6 @@ name = Main.storyboard; sourceTree = ""; }; - C0ACB10219CF104F0057B571 /* LaunchScreen.xib */ = { - isa = PBXVariantGroup; - children = ( - C0ACB10319CF104F0057B571 /* Base */, - ); - name = LaunchScreen.xib; - sourceTree = ""; - }; C0B63BA81781FAB1008D3B64 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( @@ -1050,6 +1039,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -1078,6 +1068,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; diff --git a/KeyboardTextFieldDemo/IQKeyboardManager.xcodeproj/project.xcworkspace/xcuserdata/iftekhar.xcuserdatad/UserInterfaceState.xcuserstate b/KeyboardTextFieldDemo/IQKeyboardManager.xcodeproj/project.xcworkspace/xcuserdata/iftekhar.xcuserdatad/UserInterfaceState.xcuserstate index 5012a9b..adaa15e 100644 Binary files a/KeyboardTextFieldDemo/IQKeyboardManager.xcodeproj/project.xcworkspace/xcuserdata/iftekhar.xcuserdatad/UserInterfaceState.xcuserstate and b/KeyboardTextFieldDemo/IQKeyboardManager.xcodeproj/project.xcworkspace/xcuserdata/iftekhar.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/KeyboardTextFieldDemo/KeyboardTextFieldDemo/Base.lproj/Main.storyboard b/KeyboardTextFieldDemo/KeyboardTextFieldDemo/Base.lproj/Main.storyboard index 6ec9631..c793344 100644 --- a/KeyboardTextFieldDemo/KeyboardTextFieldDemo/Base.lproj/Main.storyboard +++ b/KeyboardTextFieldDemo/KeyboardTextFieldDemo/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -533,7 +533,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -562,7 +562,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -591,7 +591,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -620,7 +620,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -649,7 +649,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -678,7 +678,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -707,7 +707,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -736,7 +736,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -765,7 +765,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -796,7 +796,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -826,7 +826,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -855,7 +855,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -884,7 +884,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -913,7 +913,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -1189,7 +1189,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -1206,7 +1206,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -1224,7 +1224,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -1241,7 +1241,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -1259,7 +1259,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -1276,7 +1276,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -1294,7 +1294,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -1311,7 +1311,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -1329,7 +1329,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -1346,7 +1346,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -1364,7 +1364,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -1381,7 +1381,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -1399,7 +1399,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -1416,7 +1416,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -1434,7 +1434,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -1451,7 +1451,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -1573,7 +1573,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - + @@ -1612,7 +1612,7 @@ textField.inputAcessoryView = [[UIView alloc] init]; - +