Keep the height limit and connect the output to it:
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *CS_TableView_Height;
Take a look at Example 3 of this tutorial .
Update the height of your view by NSNotificationCenter keyboard event using NSNotificationCenter :
- (void)viewWillAppear:(BOOL)animated { // register for keyboard notifications [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide) name:UIKeyboardWillHideNotification object:nil]; } - (void)viewWillDisappear:(BOOL)animated { // unregister for keyboard notifications while not visible. [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil]; }
You might also want to take a look at the accepted answer to this question for some inspiration.
So in the end you should get something like this:
- (void)keyboardWillShow { self.CS_TableView_Height.constant = 500;//For example [self.tableView setNeedsUpdateConstraints]; } - (void)keyboardWillHide { self.CS_TableView_Height.constant = 568;// iPhone5 height [self.tableView setNeedsUpdateConstraints]; }
Nhon nguyen
source share