最近在作一个聊天界面,要适配iOS全部屏幕。ide
之前的思路是键盘弹出的时候去改table 和输入框的frame。spa
如今发现和autolayout的约束有冲突。code
搞了半天发现须要动态改Constraint。blog
- (void)keyboardDidShow:(NSNotification *)notification { CGRect kbFrame = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; self.msgBoxBottomConstraint.constant = kbFrame.size.height; [self.messageBox needsUpdateConstraints]; } -(void)keyboardDidHide:(NSNotification*)notification { self.msgBoxBottomConstraint.constant = 0; [self.messageBox needsUpdateConstraints]; }