【发布时间】:2014-02-15 20:36:10
【问题描述】:
我有一个UITableView,每个UITableViewCell 都有一个UITextField。 When a UITextField is selected I animate the UITableView onto the screen then I change the UITableView size so that the user can see the UITableViewCell that the UITextField is in.
目前一切正常,UITableViewCell 显示在最底部,问题是当用户按下回车键时,我尝试将下一个 UITableViewCell UITextField 设置为第一响应者,然后将其滚动到视图中。 ...但是问题是下一个字段尚未加载,因此我无法访问此字段。
我想知道是否有一种方法可以初始滚动屏幕下半部分的第一个选定的 UITableViewCell / UITextField 2 or 3 up from the bottom so when enter is hit there is no worry about the nextUITextFieldnot being loaded.... currently I have tried writing an off set but it dosnt work if I select aUITextField ......这就是代码的样子。
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
CGRect rc = [textField bounds];
rc = [textField convertRect:rc toView:self.finishingTableView];
CGPoint pt = rc.origin;
pt.x = 0;
if(rc.origin.y > 200)
pt.y -= 150;
else
pt.y -= rc.origin.y;
[self.finishingTableView setContentOffset:pt animated:YES];
【问题讨论】:
-
你能用
[UITableView -scrollToRowAtIndexPath:atScrollPosition:animated:]完成你想要的吗?
标签: ios objective-c uitableview uitextfield