IQKeyboardManager not working when UITableView embedded in a container view
I've had a similar issue and fixed it using the info given here from the author of the library.
The key statement is:
library logic is to find nearest scrollView from textField. and in your case it's tableView, that is why library chooses tableView to scroll.
So the solution I've used is to disable the UITableView scroll property when the textfield/view is being edited (use the delegate methods), and then re-enable it once editing has finished. This ensures that the library does not detect the UITableView as scrollable and so it ignores it and then moves your container view instead - as you intended. Once the view has moved up as you wanted it to, you can re-enable scrolling via the UIKeyboardWillShowNotification.
So for example, for the UITextField:
-(void) textFieldDidBeginEditing:(UITextField *)textField {
[self.tableView setScrollEnabled:NO];
}
- (void) textFieldDidEndEditing:(UITextField *)textField {
[self.tableView setScrollEnabled:YES];
}
However to still allow scrolling after the view has moved up, I have registered for the keyboard notification and then allowed scrolling once the keyboard is up:
-(void) keyboardWillShow {
[self.tableView setScrollEnabled:YES];
}
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow)
name:UIKeyboardWillShowNotification
object:nil];
}
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:YES]; // This line is needed for the 'auto slide up'
// Do other stuff
}
Simple solution , No need to create observer.