【发布时间】:2012-10-31 20:23:38
【问题描述】:
我的 TableView 中有两个文本字段。 When one is selected for editing, the Textfield is moving to the center of the screen.我就是这样做的:
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
if(textField == self.nameTextField) {
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
}
else if(textField == self.passwordTextField) {
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0] atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
}
}
一切正常,但只有在键盘打开时。如果我第一次单击文本字段或键盘已关闭,则不会发生滚动。
谁能告诉我为什么或者你有其他解决方案吗?
非常感谢!
【问题讨论】:
标签: objective-c scroll uitextfield uitableview