How about this?
UITableViewCell implements user protocol MyTableViewCellLayoutDelegate
@protocol MYTableViewCellLayoutDelegate <NSObject> @required - (BOOL)shouldLayoutTableViewCell:(MYTableViewCell *)cell; @end
Create a delegate for this protocol @property (non-atomic, weak) id layoutDelegate;
Then override layoutSubviews on your UITableViewCell:
- (void)layoutSubviews { if([self.layoutDelegate shouldLayoutTableViewCell:self]) { [super layoutSubviews]; } }
Now, in your UIViewController, you can implement callLayoutTableViewCell: a callback to control the allocation of a UITableViewCell or not.
-(void)shouldLayoutTableViewCell:(UITableViewCell *)cell { return self.shouldLayoutCells; }
Modify the keyboardWillHide method to disable cell layout, call layoutIfNeeded, and restore cell layout ability in the completion block.
- (void)keyboardWillHide:(NSNotification *)notification { NSNumber *duration = [[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey]; NSNumber *curve = [[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey]; self.shouldLayoutCells = NO; [UIView animateWithDuration:duration.doubleValue delay:0 options:curve.integerValue animations:^{ _chatInputViewBottomSpaceConstraint.constant = 0; [self.view layoutIfNeeded]; } completion:completion:^(BOOL finished) { self.shouldLayoutCells = NO; }]; }
I cannot verify this because you did not provide sample code, but hopefully this puts you on the right track.
dfmuir
source share