点击底部textView,tableView当前界面最后一个ce
作者:
my__life | 来源:发表于
2016-09-12 11:15 被阅读30次
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
-(void)keyboardWillShow:(NSNotification*)note{
NSArray *cellArray = self.tableView.visibleCells;
if (cellArray.count==0) {
return;
}
CGRect keyboardFrame = [note.userInfo[UIKeyboardFrameEndUserInfoKey]CGRectValue];
UITableViewCell *cell = cellArray[cellArray.count-1];
CGFloat y = cell.frame.size.height + cell.frame.origin.y;
NSLog(@"%@",NSStringFromCGRect(keyboardFrame));
//20为导航栏,49为包裹textView的toolBarView
CGFloat newY = (y+20)-(kScreenHeight - (49+keyboardFrame.size.height));
if (newY>0) {
[self.tableView setContentOffset:CGPointMake(0, newY) animated:YES];
}
}
本文标题:点击底部textView,tableView当前界面最后一个ce
本文链接:https://www.haomeiwen.com/subject/dijpettx.html
网友评论