聊天功能弹出键盘时键盘会挡住表格文字

2016-11-08  本文已影响721人  iOS之星

要让键盘不要挡住cell只有两种方法一种是给tableview一个偏移量,让他滚动到底部, 一种是让tableview滚动到指定的cell

[self.tableViewsetContentOffset:CGPointMake(0,self.tableView.contentSize.height-UIScreenH+ kbSize.height+50)animated:NO];

kbSize是键盘的尺寸

NSIndexPath*path = [NSIndexPathindexPathForRow:self.messageArray.count-1inSection:0];

[self.tableViewscrollToRowAtIndexPath:pathatScrollPosition:UITableViewScrollPositionBottomanimated:NO];

这两种方法怎么试都会挡住cell,最后被我试好了

我试了只能这样才能保证cell不被挡住,设置偏移量前后都得刷新表格.
上一篇 下一篇

猜你喜欢

热点阅读