必须要区分IOS版本,否则你会发现很诡异的事情
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
if (IOS8) {
UITableViewCell* cell = (UITableViewCell*)[[textField superview] superview];
NSLog(@"将要开始编辑: %@ %f", textField, cell.origin.y);
[self.tableView setContentOffset:CGPointMake(0,cell.origin.y - 44) animated:YES];
}
else
{
UITableViewCell*cell = (UITableViewCell*)[[[textField superview] superview] superview];
NSLog(@"将要开始编辑: %@ %f", textField, cell.origin.y);
[self.tableView setContentOffset:CGPointMake(0,cell.origin.y - 44) animated:YES];
}
return YES;
}
本文讨论了在iOS应用开发中,如何通过检查不同iOS版本来解决文本字段编辑时出现的位置偏移问题,提供了具体的代码实现和解决思路。
1万+

被折叠的 条评论
为什么被折叠?



