Sync master

This commit is contained in:
hackiftekhar
2016-07-12 12:37:11 +05:30
parent 9bcf1f5fe9
commit 28bdf909fd
6 changed files with 240 additions and 115 deletions

View File

@@ -15,7 +15,7 @@
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>4.0</string>
<key>CFBundleSignature</key>
@@ -30,6 +30,8 @@
<array>
<string>armv7</string>
</array>
<key>UIStatusBarHidden</key>
<false/>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleDefault</string>
<key>UISupportedInterfaceOrientations</key>

View File

@@ -4,10 +4,12 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<string>com.iftekhar.IQKeyboardManagerSwift</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>

View File

@@ -138,6 +138,9 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
/** To save keyboard size. */
CGSize _kbSize;
/** To save Status Bar size. */
CGRect _statusBarFrame;
/*******************************************/
}
@@ -282,7 +285,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
-(void)setEnable:(BOOL)enable
{
// If not enabled, enable it.
if (enable == YES && _enable == NO)
if (enable == YES &&
_enable == NO)
{
//Setting NO to _enable.
_enable = enable;
@@ -293,7 +297,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
[self showLog:IQLocalizedString(@"enabled", nil)];
}
//If not disable, desable it.
else if (enable == NO && _enable == YES)
else if (enable == NO &&
_enable == YES)
{
//Sending a fake notification for keyboardWillHide to retain view's original frame.
[self keyboardWillHide:nil];
@@ -304,12 +309,14 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
[self showLog:IQLocalizedString(@"disabled", nil)];
}
//If already disabled.
else if (enable == NO && _enable == NO)
else if (enable == NO &&
_enable == NO)
{
[self showLog:IQLocalizedString(@"already disabled", nil)];
}
//If already enabled.
else if (enable == YES && _enable == YES)
else if (enable == YES &&
_enable == YES)
{
[self showLog:IQLocalizedString(@"already enabled", nil)];
}
@@ -485,7 +492,11 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
UIWindow *originalKeyWindow = [[UIApplication sharedApplication] keyWindow];
//If original key window is not nil and the cached keywindow is also not original keywindow then changing keywindow.
if (originalKeyWindow != nil && _keyWindow != originalKeyWindow) _keyWindow = originalKeyWindow;
if (originalKeyWindow != nil &&
_keyWindow != originalKeyWindow)
{
_keyWindow = originalKeyWindow;
}
return _keyWindow;
}
@@ -535,9 +546,6 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
[self showLog:[NSString stringWithFormat:@"****** %@ started ******",NSStringFromSelector(_cmd)]];
// Boolean to know keyboard is showing/hiding
_isKeyboardShowing = YES;
// Getting KeyWindow object.
UIWindow *keyWindow = [self keyWindow];
@@ -572,12 +580,14 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
NSLayoutConstraint *constraint = [[_textFieldView viewController] IQLayoutGuideConstraint];
//If topLayoutGuide constraint
if (constraint && (constraint.firstItem == [[_textFieldView viewController] topLayoutGuide] || constraint.secondItem == [[_textFieldView viewController] topLayoutGuide]))
if (constraint.firstItem == [[_textFieldView viewController] topLayoutGuide] ||
constraint.secondItem == [[_textFieldView viewController] topLayoutGuide])
{
layoutGuidePosition = IQLayoutGuidePositionTop;
}
//If bottomLayoutGuice constraint
else if (constraint && (constraint.firstItem == [[_textFieldView viewController] bottomLayoutGuide] || constraint.secondItem == [[_textFieldView viewController] bottomLayoutGuide]))
else if (constraint.firstItem == [[_textFieldView viewController] bottomLayoutGuide] ||
constraint.secondItem == [[_textFieldView viewController] bottomLayoutGuide])
{
layoutGuidePosition = IQLayoutGuidePositionBottom;
}
@@ -698,7 +708,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
UIScrollView *superScrollView = _lastScrollView;
//Looping in upper hierarchy until we don't found any scrollView in it's upper hirarchy till UIWindow object.
while (superScrollView && (move>0?(move > (-superScrollView.contentOffset.y-superScrollView.contentInset.top)):superScrollView.contentOffset.y>0) )
while (superScrollView &&
(move>0?(move > (-superScrollView.contentOffset.y-superScrollView.contentInset.top)):superScrollView.contentOffset.y>0) )
{
//Getting lastViewRect.
CGRect lastViewRect = [[lastView superview] convertRect:lastView.frame toView:superScrollView];
@@ -712,7 +723,9 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
//[_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.)
//shouldOffsetY >= 0 shouldOffsetY must be greater than in order to keep distance from navigationBar (Bug ID: #92)
if ([_textFieldView isKindOfClass:[UITextView class]] && [superScrollView superviewOfClassType:[UIScrollView class]] == nil && (shouldOffsetY >= 0))
if ([_textFieldView isKindOfClass:[UITextView class]] &&
[superScrollView superviewOfClassType:[UIScrollView class]] == nil &&
(shouldOffsetY >= 0))
{
CGFloat maintainTopLayout = 0;
@@ -968,19 +981,26 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
{
_kbShowNotification = aNotification;
// Boolean to know keyboard is showing/hiding
_isKeyboardShowing = YES;
if ([self privateIsEnabled] == NO) return;
[self showLog:[NSString stringWithFormat:@"****** %@ started ******",NSStringFromSelector(_cmd)]];
if (CGRectEqualToRect(_topViewBeginRect, CGRectZero)) // (Bug ID: #5)
if (_textFieldView != nil && CGRectEqualToRect(_topViewBeginRect, CGRectZero)) // (Bug ID: #5)
{
// keyboard is not showing(At the beginning only). We should save rootViewRect and _layoutGuideConstraintInitialConstant.
_layoutGuideConstraintInitialConstant = [[[_textFieldView viewController] IQLayoutGuideConstraint] constant];
// keyboard is not showing(At the beginning only). We should save rootViewRect.
_rootViewController = [_textFieldView topMostController];
if (_rootViewController == nil) _rootViewController = [[self keyWindow] topMostController];
_topViewBeginRect = _rootViewController.view.frame;
if (_shouldFixInteractivePopGestureRecognizer && [_rootViewController isKindOfClass:[UINavigationController class]])
if (_shouldFixInteractivePopGestureRecognizer &&
[_rootViewController isKindOfClass:[UINavigationController class]])
{
_topViewBeginRect.origin = CGPointMake(0, [self keyWindow].frame.size.height-_rootViewController.view.frame.size.height);
}
@@ -1022,7 +1042,9 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
{
//If _textFieldView is inside UIAlertView then do nothing. (Bug ID: #37, #74, #76)
//See notes:- https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html If it is UIAlertView textField then do not affect anything (Bug ID: #70).
if (_textFieldView != nil && [_textFieldView isAlertViewTextField] == NO)
if (_isKeyboardShowing == YES &&
_textFieldView != nil &&
[_textFieldView isAlertViewTextField] == NO)
{
[self adjustFrame];
}
@@ -1043,7 +1065,10 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
if (controller == nil) controller = [[self keyWindow] topMostController];
//If _textFieldView viewController is presented as formSheet, then adjustFrame again because iOS internally update formSheet frame on keyboardShown. (Bug ID: #37, #74, #76)
if (_textFieldView != nil && controller.modalPresentationStyle == UIModalPresentationFormSheet && [_textFieldView isAlertViewTextField] == NO)
if (_isKeyboardShowing == YES &&
_textFieldView != nil &&
controller.modalPresentationStyle == UIModalPresentationFormSheet &&
[_textFieldView isAlertViewTextField] == NO)
{
[self adjustFrame];
}
@@ -1116,7 +1141,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
}
// Setting rootViewController frame to it's original position. // (Bug ID: #18)
if (!CGRectEqualToRect(_topViewBeginRect, CGRectZero) && _rootViewController)
if (!CGRectEqualToRect(_topViewBeginRect, CGRectZero) &&
_rootViewController)
{
//frame size needs to be adjusted on iOS8 due to orientation API changes.
_topViewBeginRect.size = _rootViewController.view.frame.size;
@@ -1131,9 +1157,10 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
NSLayoutConstraint *constraint = [[strongSelf.textFieldView viewController] IQLayoutGuideConstraint];
//If done LayoutGuide tweak
if (constraint &&
((constraint.firstItem == [[strongSelf.textFieldView viewController] topLayoutGuide] || constraint.secondItem == [[strongSelf.textFieldView viewController] topLayoutGuide]) ||
(constraint.firstItem == [[strongSelf.textFieldView viewController] bottomLayoutGuide] || constraint.secondItem == [[strongSelf.textFieldView viewController] bottomLayoutGuide])))
if (constraint.firstItem == [[strongSelf.textFieldView viewController] topLayoutGuide] ||
constraint.firstItem == [[strongSelf.textFieldView viewController] bottomLayoutGuide] ||
constraint.secondItem == [[strongSelf.textFieldView viewController] topLayoutGuide] ||
constraint.secondItem == [[strongSelf.textFieldView viewController] bottomLayoutGuide])
{
constraint.constant = strongSelf.layoutGuideConstraintInitialConstant;
[strongSelf.rootViewController.view setNeedsLayout];
@@ -1207,7 +1234,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
[self showLog:@"adding UIToolbars if required"];
//UITextView special case. Keyboard Notification is firing before textView notification so we need to reload it's inputViews.
if ([_textFieldView isKindOfClass:[UITextView class]] && _textFieldView.inputAccessoryView == nil)
if ([_textFieldView isKindOfClass:[UITextView class]] &&
_textFieldView.inputAccessoryView == nil)
{
__weak typeof(self) weakSelf = self;
@@ -1241,7 +1269,7 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
//Adding Geture recognizer to window (Enhancement ID: #14)
[_textFieldView.window addGestureRecognizer:_tapGesture];
if (_isKeyboardShowing == NO) // (Bug ID: #5)
if (CGRectEqualToRect(_topViewBeginRect, CGRectZero)) // (Bug ID: #5)
{
// keyboard is not showing(At the beginning only). We should save rootViewRect and _layoutGuideConstraintInitialConstant.
_layoutGuideConstraintInitialConstant = [[[_textFieldView viewController] IQLayoutGuideConstraint] constant];
@@ -1251,7 +1279,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
_topViewBeginRect = _rootViewController.view.frame;
if (_shouldFixInteractivePopGestureRecognizer && [_rootViewController isKindOfClass:[UINavigationController class]])
if (_shouldFixInteractivePopGestureRecognizer &&
[_rootViewController isKindOfClass:[UINavigationController class]])
{
_topViewBeginRect.origin = CGPointMake(0, [self keyWindow].frame.size.height-_rootViewController.view.frame.size.height);
}
@@ -1261,7 +1290,9 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
//If _textFieldView is inside UIAlertView then do nothing. (Bug ID: #37, #74, #76)
//See notes:- https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html If it is UIAlertView textField then do not affect anything (Bug ID: #70).
if (_textFieldView != nil && [_textFieldView isAlertViewTextField] == NO)
if (_isKeyboardShowing == YES &&
_textFieldView != nil &&
[_textFieldView isAlertViewTextField] == NO)
{
// keyboard is already showing. adjust frame.
[self adjustFrame];
@@ -1279,7 +1310,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
[_textFieldView.window removeGestureRecognizer:_tapGesture];
// We check if there's a change in original frame or not.
if(_isTextViewContentInsetChanged == YES && [_textFieldView isKindOfClass:[UITextView class]])
if(_isTextViewContentInsetChanged == YES &&
[_textFieldView isKindOfClass:[UITextView class]])
{
UITextView *textView = (UITextView*)_textFieldView;
@@ -1306,14 +1338,15 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
[self showLog:[NSString stringWithFormat:@"****** %@ ended ******",NSStringFromSelector(_cmd)]];
}
#pragma mark - UIInterfaceOrientation Change notification methods
#pragma mark - UIStatusBar Notification methods
/** UIApplicationWillChangeStatusBarOrientationNotification. Need to set the textView to it's original position. If any frame changes made. (Bug ID: #92)*/
- (void)willChangeStatusBarOrientation:(NSNotification*)aNotification
{
[self showLog:[NSString stringWithFormat:@"****** %@ started ******",NSStringFromSelector(_cmd)]];
//If textViewContentInsetChanged is changed then restore it.
if (_isTextViewContentInsetChanged == YES && [_textFieldView isKindOfClass:[UITextView class]])
if (_isTextViewContentInsetChanged == YES &&
[_textFieldView isKindOfClass:[UITextView class]])
{
UITextView *textView = (UITextView*)_textFieldView;
@@ -1337,20 +1370,25 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
[self showLog:[NSString stringWithFormat:@"****** %@ ended ******",NSStringFromSelector(_cmd)]];
}
#pragma mark - Status Bar Frame change Notifications
/** UIApplicationDidChangeStatusBarFrameNotification. Need to refresh view position and update _topViewBeginRect. (Bug ID: #446)*/
- (void)didChangeStatusBarFrame:(NSNotification*)aNotification
{
CGRect oldStatusBarFrame = _statusBarFrame;
// Getting UIStatusBarFrame
_statusBarFrame = [[aNotification userInfo][UIApplicationStatusBarFrameUserInfoKey] CGRectValue];
if ([self privateIsEnabled] == NO) return;
[self showLog:[NSString stringWithFormat:@"****** %@ started ******",NSStringFromSelector(_cmd)]];
if (_rootViewController && !CGRectEqualToRect(_topViewBeginRect, _rootViewController.view.frame))
if (_rootViewController &&
!CGRectEqualToRect(_topViewBeginRect, _rootViewController.view.frame))
{
_topViewBeginRect = _rootViewController.view.frame;
if (_shouldFixInteractivePopGestureRecognizer && [_rootViewController isKindOfClass:[UINavigationController class]])
if (_shouldFixInteractivePopGestureRecognizer &&
[_rootViewController isKindOfClass:[UINavigationController class]])
{
_topViewBeginRect.origin = CGPointMake(0, [self keyWindow].frame.size.height-_rootViewController.view.frame.size.height);
}
@@ -1360,7 +1398,10 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
//If _textFieldView is inside UIAlertView then do nothing. (Bug ID: #37, #74, #76)
//See notes:- https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html If it is UIAlertView textField then do not affect anything (Bug ID: #70).
if (_textFieldView != nil && [_textFieldView isAlertViewTextField] == NO)
if (_isKeyboardShowing == YES &&
_textFieldView != nil &&
CGSizeEqualToSize(_statusBarFrame.size, oldStatusBarFrame.size) == NO &&
[_textFieldView isAlertViewTextField] == NO)
{
[self adjustFrame];
}
@@ -1390,7 +1431,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
// Should not recognize gesture if the clicked view is either UIControl or UINavigationBar(<Back button etc...) (Bug ID: #145)
return ([[touch view] isKindOfClass:[UIControl class]] || [[touch view] isKindOfClass:[UINavigationBar class]]) ? NO : YES;
return !([[touch view] isKindOfClass:[UIControl class]] ||
[[touch view] isKindOfClass:[UINavigationBar class]]);
}
/** Resigning textField. */
@@ -1431,7 +1473,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
NSUInteger index = [textFields indexOfObject:_textFieldView];
//If it is not first textField. then it's previous object can becomeFirstResponder.
if (index != NSNotFound && index > 0)
if (index != NSNotFound &&
index > 0)
{
return YES;
}
@@ -1451,7 +1494,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
NSUInteger index = [textFields indexOfObject:_textFieldView];
//If it is not last textField. then it's next object becomeFirstResponder.
if (index != NSNotFound && index < textFields.count-1)
if (index != NSNotFound &&
index < textFields.count-1)
{
return YES;
}
@@ -1471,7 +1515,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
NSUInteger index = [textFields indexOfObject:_textFieldView];
//If it is not first textField. then it's previous object becomeFirstResponder.
if (index != NSNotFound && index > 0)
if (index != NSNotFound &&
index > 0)
{
UITextField *nextTextField = textFields[index-1];
@@ -1507,7 +1552,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
NSUInteger index = [textFields indexOfObject:_textFieldView];
//If it is not last textField. then it's next object becomeFirstResponder.
if (index != NSNotFound && index < textFields.count-1)
if (index != NSNotFound &&
index < textFields.count-1)
{
UITextField *nextTextField = textFields[index+1];
@@ -1590,7 +1636,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
NSArray *siblings = [self responderViews];
// If only one object is found, then adding only Done button.
if (siblings.count==1 || self.shouldHidePreviousNext)
if (siblings.count==1 ||
self.shouldHidePreviousNext)
{
UITextField *textField = (UITextField*)_textFieldView;
@@ -1598,7 +1645,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
//setInputAccessoryView: check (Bug ID: #307)
if ([textField respondsToSelector:@selector(setInputAccessoryView:)])
{
if ((![textField inputAccessoryView] || ([[textField inputAccessoryView] tag] == kIQPreviousNextButtonToolbarTag)))
if (![textField inputAccessoryView] ||
[[textField inputAccessoryView] tag] == kIQPreviousNextButtonToolbarTag)
{
//Supporting Custom Done button image (Enhancement ID: #366)
if (_toolbarDoneBarButtonItemImage)
@@ -1617,7 +1665,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
}
textField.inputAccessoryView.tag = kIQDoneButtonToolbarTag; // (Bug ID: #78)
}
else if ([[textField inputAccessoryView] isKindOfClass:[IQToolbar class]] && ([[textField inputAccessoryView] tag] == kIQDoneButtonToolbarTag))
else if ([[textField inputAccessoryView] isKindOfClass:[IQToolbar class]] &&
([[textField inputAccessoryView] tag] == kIQDoneButtonToolbarTag))
{
IQToolbar *toolbar = (IQToolbar*)[textField inputAccessoryView];
@@ -1648,7 +1697,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
}
}
if ([textField.inputAccessoryView isKindOfClass:[IQToolbar class]] && textField.inputAccessoryView.tag == kIQDoneButtonToolbarTag)
if ([textField.inputAccessoryView isKindOfClass:[IQToolbar class]] &&
textField.inputAccessoryView.tag == kIQDoneButtonToolbarTag)
{
IQToolbar *toolbar = (IQToolbar*)[textField inputAccessoryView];
@@ -1686,15 +1736,22 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
}
//If need to show placeholder
if (_shouldShowTextFieldPlaceholder && textField.shouldHidePlaceholderText == NO)
if (_shouldShowTextFieldPlaceholder &&
textField.shouldHidePlaceholderText == NO)
{
//Updating placeholder //(Bug ID: #148, #272)
if (toolbar.title == nil || [toolbar.title isEqualToString:textField.drawingPlaceholderText] == NO)
if (toolbar.title == nil ||
[toolbar.title isEqualToString:textField.drawingPlaceholderText] == NO)
{
[toolbar setTitle:textField.drawingPlaceholderText];
}
//Setting toolbar title font. // (Enhancement ID: #30)
if (_placeholderFont && [_placeholderFont isKindOfClass:[UIFont class]])
if (_placeholderFont &&
[_placeholderFont isKindOfClass:[UIFont class]])
{
[toolbar setTitleFont:_placeholderFont];
}
}
else
{
@@ -1712,7 +1769,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
//setInputAccessoryView: check (Bug ID: #307)
if ([textField respondsToSelector:@selector(setInputAccessoryView:)])
{
if ((![textField inputAccessoryView] || [[textField inputAccessoryView] tag] == kIQDoneButtonToolbarTag))
if ((![textField inputAccessoryView] ||
[[textField inputAccessoryView] tag] == kIQDoneButtonToolbarTag))
{
//Supporting Custom Done button image (Enhancement ID: #366)
if (_toolbarDoneBarButtonItemImage)
@@ -1731,7 +1789,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
}
textField.inputAccessoryView.tag = kIQPreviousNextButtonToolbarTag; // (Bug ID: #78)
}
else if ([[textField inputAccessoryView] isKindOfClass:[IQToolbar class]] && ([[textField inputAccessoryView] tag] == kIQPreviousNextButtonToolbarTag))
else if ([[textField inputAccessoryView] isKindOfClass:[IQToolbar class]] &&
([[textField inputAccessoryView] tag] == kIQPreviousNextButtonToolbarTag))
{
IQToolbar *toolbar = (IQToolbar*)[textField inputAccessoryView];
@@ -1761,7 +1820,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
}
}
if ([textField.inputAccessoryView isKindOfClass:[IQToolbar class]] && textField.inputAccessoryView.tag == kIQPreviousNextButtonToolbarTag)
if ([textField.inputAccessoryView isKindOfClass:[IQToolbar class]] &&
textField.inputAccessoryView.tag == kIQPreviousNextButtonToolbarTag)
{
IQToolbar *toolbar = (IQToolbar*)[textField inputAccessoryView];
@@ -1799,15 +1859,22 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
}
//If need to show placeholder
if (_shouldShowTextFieldPlaceholder && textField.shouldHidePlaceholderText == NO)
if (_shouldShowTextFieldPlaceholder &&
textField.shouldHidePlaceholderText == NO)
{
//Updating placeholder //(Bug ID: #148, #272)
if (toolbar.title == nil || [toolbar.title isEqualToString:textField.drawingPlaceholderText] == NO)
[toolbar setTitle:textField.drawingPlaceholderText];
if (toolbar.title == nil ||
[toolbar.title isEqualToString:textField.drawingPlaceholderText] == NO)
{
[toolbar setTitle:textField.drawingPlaceholderText];
}
//Setting toolbar title font. // (Enhancement ID: #30)
if (_placeholderFont && [_placeholderFont isKindOfClass:[UIFont class]])
if (_placeholderFont &&
[_placeholderFont isKindOfClass:[UIFont class]])
{
[toolbar setTitleFont:_placeholderFont];
}
}
else
{
@@ -1847,7 +1914,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
// (Bug ID: #78)
//setInputAccessoryView: check (Bug ID: #307)
if ([textField respondsToSelector:@selector(setInputAccessoryView:)] && ([toolbar isKindOfClass:[IQToolbar class]] && (toolbar.tag == kIQDoneButtonToolbarTag || toolbar.tag == kIQPreviousNextButtonToolbarTag)))
if ([textField respondsToSelector:@selector(setInputAccessoryView:)] &&
([toolbar isKindOfClass:[IQToolbar class]] && (toolbar.tag == kIQDoneButtonToolbarTag || toolbar.tag == kIQPreviousNextButtonToolbarTag)))
{
textField.inputAccessoryView = nil;
}
@@ -1902,7 +1970,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
BOOL isAcceptAsFirstResponder = [self goPrevious];
if (isAcceptAsFirstResponder == YES && textFieldRetain.previousInvocation)
if (isAcceptAsFirstResponder == YES &&
textFieldRetain.previousInvocation)
{
[textFieldRetain.previousInvocation invoke];
}
@@ -1924,7 +1993,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
BOOL isAcceptAsFirstResponder = [self goNext];
if (isAcceptAsFirstResponder == YES && textFieldRetain.nextInvocation)
if (isAcceptAsFirstResponder == YES &&
textFieldRetain.nextInvocation)
{
[textFieldRetain.nextInvocation invoke];
}
@@ -1944,7 +2014,8 @@ NSInteger const kIQPreviousNextButtonToolbarTag = -1005;
BOOL isResignedFirstResponder = [self resignFirstResponder];
if (isResignedFirstResponder == YES && textFieldRetain.doneInvocation)
if (isResignedFirstResponder == YES &&
textFieldRetain.doneInvocation)
{
[textFieldRetain.doneInvocation invoke];
}

View File

@@ -25,7 +25,7 @@
#import "IQKeyboardManagerConstants.h"
#import "IQKeyboardManagerConstantsInternal.h"
#import <UIKit/UILabel.h>
#import <UIKIt/UIButton.h>
#import <UIKit/UIButton.h>
@implementation IQTitleBarButtonItem
{

View File

@@ -62,13 +62,15 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
didSet {
//If not enable, enable it.
if enable == true && oldValue == false {
if enable == true &&
oldValue == false {
//If keyboard is currently showing. Sending a fake notification for keyboardWillShow to adjust view according to keyboard.
if _kbShowNotification != nil {
keyboardWillShow(_kbShowNotification)
}
showLog("enabled")
} else if enable == false && oldValue == true { //If not disable, desable it.
} else if enable == false &&
oldValue == true { //If not disable, desable it.
keyboardWillHide(nil)
showLog("disabled")
}
@@ -474,7 +476,9 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
if let textFieldRetain = _textFieldView {
let isAcceptAsFirstResponder = goPrevious()
if isAcceptAsFirstResponder && textFieldRetain.previousInvocation.target != nil && textFieldRetain.previousInvocation.action != nil {
if isAcceptAsFirstResponder &&
textFieldRetain.previousInvocation.target != nil &&
textFieldRetain.previousInvocation.action != nil {
UIApplication.sharedApplication().sendAction(textFieldRetain.previousInvocation.action!, to: textFieldRetain.previousInvocation.target, from: textFieldRetain, forEvent: UIEvent())
}
@@ -496,7 +500,9 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
if let textFieldRetain = _textFieldView {
let isAcceptAsFirstResponder = goNext()
if isAcceptAsFirstResponder && textFieldRetain.nextInvocation.target != nil && textFieldRetain.nextInvocation.action != nil {
if isAcceptAsFirstResponder &&
textFieldRetain.nextInvocation.target != nil &&
textFieldRetain.nextInvocation.action != nil {
UIApplication.sharedApplication().sendAction(textFieldRetain.nextInvocation.action!, to: textFieldRetain.nextInvocation.target, from: textFieldRetain, forEvent: UIEvent())
}
@@ -517,7 +523,9 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
//Resign textFieldView.
let isResignedFirstResponder = resignFirstResponder()
if isResignedFirstResponder && textFieldRetain.doneInvocation.target != nil && textFieldRetain.doneInvocation.action != nil{
if isResignedFirstResponder &&
textFieldRetain.doneInvocation.target != nil &&
textFieldRetain.doneInvocation.action != nil{
UIApplication.sharedApplication().sendAction(textFieldRetain.doneInvocation.action!, to: textFieldRetain.doneInvocation.target, from: textFieldRetain, forEvent: UIEvent())
}
@@ -542,7 +550,8 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
/** To not detect touch events in a subclass of UIControl, these may have added their own selector for specific work */
public func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
// Should not recognize gesture if the clicked view is either UIControl or UINavigationBar(<Back button etc...) (Bug ID: #145)
return (touch.view is UIControl || touch.view is UINavigationBar) ? false : true
return !(touch.view is UIControl ||
touch.view is UINavigationBar)
}
///-----------------------
@@ -673,6 +682,9 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
/** To save keyboard size. */
private var _kbSize = CGSizeZero
/** To save Status Bar size. */
private var _statusBarFrame = CGRectZero
/** To save keyboard animation duration. */
private var _animationDuration = 0.25
@@ -778,7 +790,8 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
let originalKeyWindow = UIApplication.sharedApplication().keyWindow
//If original key window is not nil and the cached keywindow is also not original keywindow then changing keywindow.
if originalKeyWindow != nil && (Static.keyWindow == nil || Static.keyWindow != originalKeyWindow) {
if originalKeyWindow != nil &&
(Static.keyWindow == nil || Static.keyWindow != originalKeyWindow) {
Static.keyWindow = originalKeyWindow
}
@@ -840,9 +853,6 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
showLog("****** \(#function) %@ started ******")
// Boolean to know keyboard is showing/hiding
_keyboardManagerFlags.isKeyboardShowing = true
// Getting KeyWindow object.
let optionalWindow = keyWindow()
@@ -855,7 +865,9 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
// Converting Rectangle according to window bounds.
let optionalTextFieldViewRect = textFieldView.superview?.convertRect(textFieldView.frame, toView: optionalWindow)
if optionalRootController == nil || optionalWindow == nil || optionalTextFieldViewRect == nil {
if optionalRootController == nil ||
optionalWindow == nil ||
optionalTextFieldViewRect == nil {
return
}
@@ -1021,7 +1033,9 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
//[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 {
if textFieldView is UITextView == true &&
scrollView.superviewOfClassType(UIScrollView) == nil &&
shouldOffsetY >= 0 {
var maintainTopLayout : CGFloat = 0
if let navigationBarFrame = textFieldView.viewController()?.navigationController?.navigationBar.frame {
@@ -1162,7 +1176,8 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
}
// Special case for iPad modalPresentationStyle.
if rootController.modalPresentationStyle == UIModalPresentationStyle.FormSheet || rootController.modalPresentationStyle == UIModalPresentationStyle.PageSheet {
if rootController.modalPresentationStyle == UIModalPresentationStyle.FormSheet ||
rootController.modalPresentationStyle == UIModalPresentationStyle.PageSheet {
showLog("Found Special case for Model Presentation Style: \(rootController.modalPresentationStyle)")
@@ -1260,6 +1275,9 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
_kbShowNotification = notification
// Boolean to know keyboard is showing/hiding
_keyboardManagerFlags.isKeyboardShowing = true
if privateIsEnabled() == false {
return
}
@@ -1267,7 +1285,13 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
showLog("****** \(#function) started ******")
// (Bug ID: #5)
if CGRectEqualToRect(_topViewBeginRect, CGRectZero) == true {
if _textFieldView != nil && CGRectEqualToRect(_topViewBeginRect, CGRectZero) == true {
// keyboard is not showing(At the beginning only). We should save rootViewRect.
if let constant = _textFieldView?.viewController()?.IQLayoutGuideConstraint?.constant {
_layoutGuideConstraintInitialConstant = constant
}
// keyboard is not showing(At the beginning only). We should save rootViewRect.
_rootViewController = _textFieldView?.topMostController()
if _rootViewController == nil {
@@ -1277,7 +1301,8 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
if let unwrappedRootController = _rootViewController {
_topViewBeginRect = unwrappedRootController.view.frame
if shouldFixInteractivePopGestureRecognizer == true && unwrappedRootController is UINavigationController {
if shouldFixInteractivePopGestureRecognizer == true &&
unwrappedRootController is UINavigationController {
if let window = keyWindow() {
_topViewBeginRect.origin = CGPointMake(0,window.frame.size.height-unwrappedRootController.view.frame.size.height)
@@ -1344,14 +1369,12 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
//If _textFieldView is inside UITableViewController then let UITableViewController to handle it (Bug ID: #37) (Bug ID: #76) See note:- https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html If it is UIAlertView textField then do not affect anything (Bug ID: #70).
if _textFieldView != nil && _textFieldView?.isAlertViewTextField() == false {
if _keyboardManagerFlags.isKeyboardShowing == true &&
_textFieldView != nil &&
_textFieldView?.isAlertViewTextField() == false {
//Getting textField viewController
if _textFieldView?.viewController() != nil {
// keyboard is already showing. adjust frame.
adjustFrame()
}
// keyboard is already showing. adjust frame.
adjustFrame()
}
}
@@ -1374,7 +1397,9 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
topMostController = keyWindow()?.topMostController()
}
if _textFieldView != nil && topMostController?.modalPresentationStyle == UIModalPresentationStyle.FormSheet && _textFieldView?.isAlertViewTextField() == false {
if _textFieldView != nil &&
topMostController?.modalPresentationStyle == UIModalPresentationStyle.FormSheet &&
_textFieldView?.isAlertViewTextField() == false {
// keyboard is already showing. adjust frame.
adjustFrame()
@@ -1476,7 +1501,8 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
if let itemLayoutGuide : UILayoutSupport = layoutGuide {
if (itemLayoutGuide === viewController.topLayoutGuide || itemLayoutGuide === viewController.bottomLayoutGuide)
if (itemLayoutGuide === viewController.topLayoutGuide ||
itemLayoutGuide === viewController.bottomLayoutGuide)
{
constraint.constant = self._layoutGuideConstraintInitialConstant
rootViewController.view.setNeedsLayout()
@@ -1564,7 +1590,8 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
showLog("adding UIToolbars if required")
//UITextView special case. Keyboard Notification is firing before textView notification so we need to resign it first and then again set it as first responder to add toolbar on it.
if _textFieldView is UITextView == true && _textFieldView?.inputAccessoryView == nil {
if _textFieldView is UITextView == true &&
_textFieldView?.inputAccessoryView == nil {
UIView.animateWithDuration(0.00001, delay: 0, options: UIViewAnimationOptions.BeginFromCurrentState.union(_animationCurve), animations: { () -> Void in
@@ -1590,7 +1617,7 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
_textFieldView?.window?.addGestureRecognizer(_tapGesture) // (Enhancement ID: #14)
if _keyboardManagerFlags.isKeyboardShowing == false { // (Bug ID: #5)
if CGRectEqualToRect(_topViewBeginRect, CGRectZero) == true { // (Bug ID: #5)
// keyboard is not showing(At the beginning only). We should save rootViewRect.
if let constant = _textFieldView?.viewController()?.IQLayoutGuideConstraint?.constant {
@@ -1606,7 +1633,8 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
_topViewBeginRect = rootViewController.view.frame
if shouldFixInteractivePopGestureRecognizer == true && rootViewController is UINavigationController {
if shouldFixInteractivePopGestureRecognizer == true &&
rootViewController is UINavigationController {
if let window = keyWindow() {
_topViewBeginRect.origin = CGPointMake(0,window.frame.size.height-rootViewController.view.frame.size.height)
} else {
@@ -1620,7 +1648,9 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
//If _textFieldView is inside ignored responder then do nothing. (Bug ID: #37, #74, #76)
//See notes:- https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html If it is UIAlertView textField then do not affect anything (Bug ID: #70).
if _textFieldView != nil && _textFieldView?.isAlertViewTextField() == false {
if _keyboardManagerFlags.isKeyboardShowing == true &&
_textFieldView != nil &&
_textFieldView?.isAlertViewTextField() == false {
// keyboard is already showing. adjust frame.
adjustFrame()
@@ -1664,7 +1694,7 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
}
///------------------------------------------
/// MARK: Interface Orientation Notifications
/// MARK: UIStatusBar Notification methods
///------------------------------------------
/** UIApplicationWillChangeStatusBarOrientationNotification. Need to set the textView to it's original position. If any frame changes made. (Bug ID: #92)*/
@@ -1694,25 +1724,31 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
showLog("****** \(#function) ended ******")
}
///------------------------------------------
/// MARK: Status Bar Frame change Notifications
///------------------------------------------
/** UIApplicationDidChangeStatusBarFrameNotification. Need to refresh view position and update _topViewBeginRect. (Bug ID: #446)*/
internal func didChangeStatusBarFrame(notification : NSNotification?) -> Void {
let oldStatusBarFrame = _statusBarFrame;
// Getting keyboard animation duration
if let newFrame = notification?.userInfo?[UIApplicationStatusBarFrameUserInfoKey]?.CGRectValue() {
_statusBarFrame = newFrame
}
if privateIsEnabled() == false {
return
}
showLog("****** \(#function) started ******")
if _rootViewController != nil && !CGRectEqualToRect(_topViewBeginRect, _rootViewController!.view.frame) == true {
if _rootViewController != nil &&
!CGRectEqualToRect(_topViewBeginRect, _rootViewController!.view.frame) == true {
if let unwrappedRootController = _rootViewController {
_topViewBeginRect = unwrappedRootController.view.frame
if shouldFixInteractivePopGestureRecognizer == true && unwrappedRootController is UINavigationController {
if shouldFixInteractivePopGestureRecognizer == true &&
unwrappedRootController is UINavigationController {
if let window = keyWindow() {
_topViewBeginRect.origin = CGPointMake(0,window.frame.size.height-unwrappedRootController.view.frame.size.height)
@@ -1729,14 +1765,13 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
//If _textFieldView is inside UITableViewController then let UITableViewController to handle it (Bug ID: #37) (Bug ID: #76) See note:- https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html If it is UIAlertView textField then do not affect anything (Bug ID: #70).
if _textFieldView != nil && _textFieldView?.isAlertViewTextField() == false {
if _keyboardManagerFlags.isKeyboardShowing == true &&
_textFieldView != nil &&
CGSizeEqualToSize(_statusBarFrame.size, oldStatusBarFrame.size) == false &&
_textFieldView?.isAlertViewTextField() == false {
//Getting textField viewController
if _textFieldView?.viewController() != nil {
// keyboard is already showing. adjust frame.
adjustFrame()
}
// keyboard is already showing. adjust frame.
adjustFrame()
}
showLog("****** \(#function) ended ******")
@@ -1792,14 +1827,16 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
if let siblings = responderViews() {
// If only one object is found, then adding only Done button.
if siblings.count == 1 || shouldHidePreviousNext == true {
if siblings.count == 1 ||
shouldHidePreviousNext == true {
if let textField = _textFieldView {
//Either there is no inputAccessoryView or if accessoryView is not appropriate for current situation(There is Previous/Next/Done toolbar).
//setInputAccessoryView: check (Bug ID: #307)
if textField.respondsToSelector(Selector("setInputAccessoryView:")) {
if textField.inputAccessoryView == nil || textField.inputAccessoryView?.tag == IQKeyboardManager.kIQPreviousNextButtonToolbarTag {
if textField.inputAccessoryView == nil ||
textField.inputAccessoryView?.tag == IQKeyboardManager.kIQPreviousNextButtonToolbarTag {
//Supporting Custom Done button image (Enhancement ID: #366)
if let doneBarButtonItemImage = toolbarDoneBarButtonItemImage {
textField.addRightButtonOnKeyboardWithImage(doneBarButtonItemImage, target: self, action: #selector(self.doneAction(_:)), shouldShowPlaceholder: shouldShowTextFieldPlaceholder)
@@ -1836,7 +1873,8 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
textField.inputAccessoryView?.tag = IQKeyboardManager.kIQDoneButtonToolbarTag // (Bug ID: #78)
}
if textField.inputAccessoryView is IQToolbar && textField.inputAccessoryView?.tag == IQKeyboardManager.kIQDoneButtonToolbarTag {
if textField.inputAccessoryView is IQToolbar &&
textField.inputAccessoryView?.tag == IQKeyboardManager.kIQDoneButtonToolbarTag {
let toolbar = textField.inputAccessoryView as! IQToolbar
@@ -1883,10 +1921,12 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
}
//Setting toolbar title font. // (Enhancement ID: #30)
if shouldShowTextFieldPlaceholder == true && textField.shouldHidePlaceholderText == false {
if shouldShowTextFieldPlaceholder == true &&
textField.shouldHidePlaceholderText == false {
//Updating placeholder font to toolbar. //(Bug ID: #148, #272)
if toolbar.title == nil || toolbar.title != textField.drawingPlaceholderText {
if toolbar.title == nil ||
toolbar.title != textField.drawingPlaceholderText {
toolbar.title = textField.drawingPlaceholderText
}
@@ -1903,7 +1943,8 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
//setInputAccessoryView: check (Bug ID: #307)
if textField.respondsToSelector(Selector("setInputAccessoryView:")) {
if textField.inputAccessoryView == nil || textField.inputAccessoryView?.tag == IQKeyboardManager.kIQPreviousNextButtonToolbarTag {
if textField.inputAccessoryView == nil ||
textField.inputAccessoryView?.tag == IQKeyboardManager.kIQPreviousNextButtonToolbarTag {
//Supporting Custom Done button image (Enhancement ID: #366)
if let doneBarButtonItemImage = toolbarDoneBarButtonItemImage {
textField.addRightButtonOnKeyboardWithImage(doneBarButtonItemImage, target: self, action: #selector(self.doneAction(_:)), shouldShowPlaceholder: shouldShowTextFieldPlaceholder)
@@ -1940,7 +1981,8 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
textField.inputAccessoryView?.tag = IQKeyboardManager.kIQDoneButtonToolbarTag // (Bug ID: #78)
}
if textField.inputAccessoryView is IQToolbar && textField.inputAccessoryView?.tag == IQKeyboardManager.kIQDoneButtonToolbarTag {
if textField.inputAccessoryView is IQToolbar &&
textField.inputAccessoryView?.tag == IQKeyboardManager.kIQDoneButtonToolbarTag {
let toolbar = textField.inputAccessoryView as! IQToolbar
@@ -1987,10 +2029,12 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
}
//Setting toolbar title font. // (Enhancement ID: #30)
if shouldShowTextFieldPlaceholder == true && textField.shouldHidePlaceholderText == false {
if shouldShowTextFieldPlaceholder == true &&
textField.shouldHidePlaceholderText == false {
//Updating placeholder font to toolbar. //(Bug ID: #148, #272)
if toolbar.title == nil || toolbar.title != textField.drawingPlaceholderText {
if toolbar.title == nil ||
toolbar.title != textField.drawingPlaceholderText {
toolbar.title = textField.drawingPlaceholderText
}
@@ -2011,9 +2055,11 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
//Either there is no inputAccessoryView or if accessoryView is not appropriate for current situation(There is Done toolbar).
//setInputAccessoryView: check (Bug ID: #307)
if textField.respondsToSelector(Selector("setInputAccessoryView:")) && (textField.inputAccessoryView == nil || textField.inputAccessoryView?.tag == IQKeyboardManager.kIQDoneButtonToolbarTag) {
if textField.respondsToSelector(Selector("setInputAccessoryView:")) &&
(textField.inputAccessoryView == nil || textField.inputAccessoryView?.tag == IQKeyboardManager.kIQDoneButtonToolbarTag) {
if textField.inputAccessoryView == nil || textField.inputAccessoryView?.tag == IQKeyboardManager.kIQDoneButtonToolbarTag {
if textField.inputAccessoryView == nil ||
textField.inputAccessoryView?.tag == IQKeyboardManager.kIQDoneButtonToolbarTag {
//Supporting Custom Done button image (Enhancement ID: #366)
if let doneBarButtonItemImage = toolbarDoneBarButtonItemImage {
textField.addPreviousNextRightOnKeyboardWithTarget(self, rightButtonImage: doneBarButtonItemImage, previousAction: #selector(self.previousAction(_:)), nextAction: #selector(self.nextAction(_:)), rightButtonAction: #selector(self.doneAction(_:)), shouldShowPlaceholder: shouldShowTextFieldPlaceholder)
@@ -2050,7 +2096,8 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
textField.inputAccessoryView?.tag = IQKeyboardManager.kIQPreviousNextButtonToolbarTag // (Bug ID: #78)
}
if textField.inputAccessoryView is IQToolbar && textField.inputAccessoryView?.tag == IQKeyboardManager.kIQPreviousNextButtonToolbarTag {
if textField.inputAccessoryView is IQToolbar &&
textField.inputAccessoryView?.tag == IQKeyboardManager.kIQPreviousNextButtonToolbarTag {
let toolbar = textField.inputAccessoryView as! IQToolbar
@@ -2096,10 +2143,12 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
}
//Setting toolbar title font. // (Enhancement ID: #30)
if shouldShowTextFieldPlaceholder == true && textField.shouldHidePlaceholderText == false {
if shouldShowTextFieldPlaceholder == true &&
textField.shouldHidePlaceholderText == false {
//Updating placeholder font to toolbar. //(Bug ID: #148, #272)
if toolbar.title == nil || toolbar.title != textField.drawingPlaceholderText {
if toolbar.title == nil ||
toolbar.title != textField.drawingPlaceholderText {
toolbar.title = textField.drawingPlaceholderText
}
@@ -2139,7 +2188,8 @@ public class IQKeyboardManager: NSObject, UIGestureRecognizerDelegate {
if let toolbar = view.inputAccessoryView as? IQToolbar {
//setInputAccessoryView: check (Bug ID: #307)
if view.respondsToSelector(Selector("setInputAccessoryView:")) && (toolbar.tag == IQKeyboardManager.kIQDoneButtonToolbarTag || toolbar.tag == IQKeyboardManager.kIQPreviousNextButtonToolbarTag) {
if view.respondsToSelector(Selector("setInputAccessoryView:")) &&
(toolbar.tag == IQKeyboardManager.kIQDoneButtonToolbarTag || toolbar.tag == IQKeyboardManager.kIQPreviousNextButtonToolbarTag) {
if let textField = view as? UITextField {
textField.inputAccessoryView = nil