【发布时间】:2014-09-13 14:55:30
【问题描述】:
我在 TableView 中有一个文本框,当用户选择一个开关时,它会出现(变得可见)并弹出一个键盘,当用户关闭开关时,TextBox 消失并且键盘隐藏。在键盘出现和消失的时间里,我想将 tableView 稍微向上移动,然后回到原来的位置。这是代码
-(IBAction)actionSwitch:(id)sender
{
isSearchTerm = [switchSearchTerm isOn];
[self.tableView reloadData];
if(isSearchTerm == YES)
{
[txtSearchTerm becomeFirstResponder];
floatBottom = self.tableView.contentInset.bottom;
self.tableView.contentInset=UIEdgeInsetsMake(0,0,200,0);
[self.tableView scrollToRowAtIndexPath:[self.tableView indexPathForSelectedRow] atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
else
{
[txtSearchTerm resignFirstResponder];
self.tableView.contentInset=UIEdgeInsetsMake(0,0,floatBottom,0);
[self.tableView scrollToRowAtIndexPath:[self.tableView indexPathForSelectedRow] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
}
}
else 部分无法将 tableview 恢复到原来的位置,请帮忙。
【问题讨论】:
标签: ios uitableview uiresponder