想必大家会遇到cell里添加textView输入框的需求,这遇见两个问题: 自动计算输入框的高度,以及键盘弹起不能遮盖输入框。此次项目遇见这个问题在此和大家探讨一下。(在此使用YYText)
1.注册键盘通知
//注册通知,监听键盘弹起事件
[[NSNotificationCenterdefaultCenter]addObserver:self
selector:@selector(handleKeyboardDidShow:)
name:UIKeyboardWillShowNotification
object:nil];
//注册通知,监听键盘消失事件
[[NSNotificationCenterdefaultCenter]addObserver:self
selector:@selector(handleKeyboardDidHidden)
name:UIKeyboardWillHideNotification
object:nil];
-(void)textViewDidChange:(YYTextView *)textView{