Skip to content

Commit 17928e0

Browse files
committed
Fixed #204, added 'BOOL layoutIfNeededOnUpdate', but it defaults to YES
1 parent 95474f5 commit 17928e0

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

IQKeyBoardManager/IQKeyboardManager.h

+5
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ extern NSInteger const kIQPreviousNextButtonToolbarTag;
206206
*/
207207
@property(nonatomic, assign) BOOL shouldAdoptDefaultKeyboardAnimation;
208208

209+
/**
210+
If YES, then calls 'setNeedsLayout' and 'layoutIfNeeded' on any frame update of to viewController's view.
211+
*/
212+
@property(nonatomic, assign) BOOL layoutIfNeededOnUpdate;
213+
209214
///------------------------------------
210215
/// @name Class Level disabling methods
211216
///------------------------------------

IQKeyBoardManager/IQKeyboardManager.m

+15-6
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ -(instancetype)init
261261
[self setShouldAdoptDefaultKeyboardAnimation:YES];
262262
[self setShouldRestoreScrollViewContentOffset:NO];
263263
[self setToolbarManageBehaviour:IQAutoToolbarBySubviews];
264+
[self setLayoutIfNeededOnUpdate:YES];
264265

265266
//Initializing disabled classes Set.
266267
_disabledClasses = [[NSMutableSet alloc] initWithObjects:[UITableViewController class], nil];
@@ -432,9 +433,13 @@ -(void)setRootViewFrame:(CGRect)frame
432433
// Setting it's new frame
433434
[controller.view setFrame:frame];
434435

435-
//Animating content (Bug ID: #160)
436-
[controller.view setNeedsLayout];
437-
[controller.view layoutIfNeeded];
436+
//Animating content if needed (Bug ID: #204)
437+
if (_layoutIfNeededOnUpdate)
438+
{
439+
//Animating content (Bug ID: #160)
440+
[controller.view setNeedsLayout];
441+
[controller.view layoutIfNeeded];
442+
}
438443

439444
_IQShowLog([NSString stringWithFormat:@"Set %@ frame to : %@",[controller _IQDescription],NSStringFromCGRect(frame)]);
440445
} completion:NULL];
@@ -1076,9 +1081,13 @@ - (void)keyboardWillHide:(NSNotification*)aNotification
10761081
// Setting it's new frame
10771082
[_rootViewController.view setFrame:_topViewBeginRect];
10781083

1079-
//Animating content (Bug ID: #160)
1080-
[_rootViewController.view setNeedsLayout];
1081-
[_rootViewController.view layoutIfNeeded];
1084+
//Animating content if needed (Bug ID: #204)
1085+
if (_layoutIfNeededOnUpdate)
1086+
{
1087+
//Animating content (Bug ID: #160)
1088+
[_rootViewController.view setNeedsLayout];
1089+
[_rootViewController.view layoutIfNeeded];
1090+
}
10821091

10831092
} completion:NULL];
10841093
_rootViewController = nil;

0 commit comments

Comments
 (0)