当键盘出现时如何向上滚动UITableviewcell? [英] How to scroll the UITableviewcell scroll up when the keyboard appears?
本文介绍了当键盘出现时如何向上滚动UITableviewcell?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
表格视图在文本字段开始编辑iphone时滚动
我在UITableview中加载了很多UITextField。最大值我在UITableView单元格中有15个UITextField。当键盘/ UIActionSheet(UIPickerView)出现时,我想向上移动(滚动)Cell。请建议/指导我任何示例代码来解决此问题。提前致谢。
I have loaded many UITextFields in UITableview. Maximum i have 15 UITextFields in UITableView cells. I want to move(Scroll) up the the Cell when the Keyboard/UIActionSheet(UIPickerView) appears. Please suggest/guide me any sample code to solve this problem. Thanks in advance.
推荐答案
请在 -textFieldShouldBeginEditing
....中尝试以下代码/ p>
Please try below code in -textFieldShouldBeginEditing
....
self.tblView.frame= CGRectMake(self.tblView.frame.origin.x, self.tblView.frame.origin.y, self.tblView.frame.size.width, self.tblView.frame.size.height - 190);
NSIndexPath *indexPath =[NSIndexPath indexPathForRow:nIndex inSection:nSectionIndex];
[self.tblView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
谢谢
这篇关于当键盘出现时如何向上滚动UITableviewcell?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文