Skip to content

Commit

Permalink
Fixed an issue where toolbar text start displayed from left in iOS11
Browse files Browse the repository at this point in the history
  • Loading branch information
hackiftekhar committed Aug 21, 2017
1 parent 1bfea32 commit 74b64a1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
6 changes: 3 additions & 3 deletions IQKeyboardManager/Categories/IQUIView+Hierarchy.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ -(UIViewController*)viewController

-(UIViewController *)topMostController
{
NSMutableArray *controllersHierarchy = [[NSMutableArray alloc] init];
NSMutableArray<UIViewController*> *controllersHierarchy = [[NSMutableArray alloc] init];

UIViewController *topController = self.window.rootViewController;

Expand Down Expand Up @@ -147,7 +147,7 @@ - (NSArray*)responderSiblings
NSArray *siblings = self.superview.subviews;

//Array of (UITextField/UITextView's).
NSMutableArray *tempTextFields = [[NSMutableArray alloc] init];
NSMutableArray<UIView*> *tempTextFields = [[NSMutableArray alloc] init];

for (UIView *textField in siblings)
if ([textField _IQcanBecomeFirstResponder])
Expand All @@ -158,7 +158,7 @@ - (NSArray*)responderSiblings

- (NSArray*)deepResponderViews
{
NSMutableArray *textFields = [[NSMutableArray alloc] init];
NSMutableArray<UIView*> *textFields = [[NSMutableArray alloc] init];

for (UIView *textField in self.subviews)
{
Expand Down
25 changes: 17 additions & 8 deletions IQKeyboardManager/IQToolbar/IQUIView+IQKeyboardToolbar.m
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,11 @@ - (void)addRightButtonOnKeyboardWithImage:(UIImage*)image target:(id)target acti
}
}

NSMutableArray *items = [[NSMutableArray alloc] init];
NSMutableArray<UIBarButtonItem*> *items = [[NSMutableArray alloc] init];

//Flexible space
[items addObject:[[self class] flexibleBarButtonItem]];

//Title button
toolbar.titleBarButton.title = self.shouldHideToolbarPlaceholder?nil:titleText;
if (IQ_IS_IOS11_OR_GREATER == NO)
Expand Down Expand Up @@ -225,8 +228,11 @@ - (void)addRightButtonOnKeyboardWithText:(NSString*)text target:(id)target actio
}
}

NSMutableArray *items = [[NSMutableArray alloc] init];
NSMutableArray<UIBarButtonItem*> *items = [[NSMutableArray alloc] init];

//Flexible space
[items addObject:[[self class] flexibleBarButtonItem]];

//Title button
toolbar.titleBarButton.title = self.shouldHideToolbarPlaceholder?nil:titleText;
if (IQ_IS_IOS11_OR_GREATER == NO)
Expand Down Expand Up @@ -297,7 +303,10 @@ - (void)addDoneOnKeyboardWithTarget:(id)target action:(SEL)action titleText:(NSS
}
}

NSMutableArray *items = [[NSMutableArray alloc] init];
NSMutableArray<UIBarButtonItem*> *items = [[NSMutableArray alloc] init];

//Flexible space
[items addObject:[[self class] flexibleBarButtonItem]];

//Title button
toolbar.titleBarButton.title = self.shouldHideToolbarPlaceholder?nil:titleText;
Expand Down Expand Up @@ -361,7 +370,7 @@ - (void)addLeftRightOnKeyboardWithTarget:(id)target leftButtonTitle:(NSString*)l
}
}

NSMutableArray *items = [[NSMutableArray alloc] init];
NSMutableArray<UIBarButtonItem*> *items = [[NSMutableArray alloc] init];

//Left button
IQBarButtonItem *cancelButton = toolbar.previousBarButton;
Expand Down Expand Up @@ -453,7 +462,7 @@ - (void)addCancelDoneOnKeyboardWithTarget:(id)target cancelAction:(SEL)cancelAct
}
}

NSMutableArray *items = [[NSMutableArray alloc] init];
NSMutableArray<UIBarButtonItem*> *items = [[NSMutableArray alloc] init];

//Cancel button
IQBarButtonItem *cancelButton = toolbar.previousBarButton;
Expand Down Expand Up @@ -531,7 +540,7 @@ - (void)addPreviousNextDoneOnKeyboardWithTarget:(id)target previousAction:(SEL)p
}
}

NSMutableArray *items = [[NSMutableArray alloc] init];
NSMutableArray<UIBarButtonItem*> *items = [[NSMutableArray alloc] init];

// Get the top level "bundle" which may actually be the framework
NSBundle *mainBundle = [NSBundle bundleForClass:[IQKeyboardManager class]];
Expand Down Expand Up @@ -676,7 +685,7 @@ - (void)addPreviousNextRightOnKeyboardWithTarget:(id)target rightButtonImage:(UI
}
}

NSMutableArray *items = [[NSMutableArray alloc] init];
NSMutableArray<UIBarButtonItem*> *items = [[NSMutableArray alloc] init];

// Get the top level "bundle" which may actually be the framework
NSBundle *mainBundle = [NSBundle bundleForClass:[IQKeyboardManager class]];
Expand Down Expand Up @@ -820,7 +829,7 @@ - (void)addPreviousNextRightOnKeyboardWithTarget:(id)target rightButtonTitle:(NS
}
}

NSMutableArray *items = [[NSMutableArray alloc] init];
NSMutableArray<UIBarButtonItem*> *items = [[NSMutableArray alloc] init];

// Get the top level "bundle" which may actually be the framework
NSBundle *mainBundle = [NSBundle bundleForClass:[IQKeyboardManager class]];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ public extension UIView {

var items : [IQBarButtonItem] = []

//Flexible space
items.append(UIView.flexibleBarButtonItem())

//Title button
toolbar.titleBarButton.title = shouldHideToolbarPlaceholder == true ? nil : titleText

Expand Down Expand Up @@ -312,6 +315,9 @@ public extension UIView {

var items : [IQBarButtonItem] = []

//Flexible space
items.append(UIView.flexibleBarButtonItem())

//Title button
toolbar.titleBarButton.title = shouldHideToolbarPlaceholder == true ? nil : titleText

Expand Down Expand Up @@ -419,6 +425,9 @@ public extension UIView {

var items : [IQBarButtonItem] = []

//Flexible space
items.append(UIView.flexibleBarButtonItem())

//Title button
toolbar.titleBarButton.title = shouldHideToolbarPlaceholder == true ? nil : titleText

Expand Down

0 comments on commit 74b64a1

Please sign in to comment.