키보드가 표시되어있는 동안 UITableView에서 스크롤하려고합니다. TableView의 크기를 조정하여 키보드로 덮지 않습니다. 내 UITableView에서 다음 UITextField로 건너 뛰려면 textFieldShouldReturn 함수를 덮어 쓰고 다음 필드로 스크롤하십시오. 그러나UITableView가 올바르게 스크롤되지 않거나 전혀 표시되지 않습니다.
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
UITableViewCell *cell = (UITableViewCell *)[textField superview];
NSIndexPath *indexPath = [self.prefTableView indexPathForCell:cell];
NSString *nextRowKey = [preferences nextRowKeyAtIndexPath:indexPath];
[textField resignFirstResponder];
if (nextRowKey != nil) {
tagBeingEdited = textField.tag + 1;
NSIndexPath *nextIndexPath = [NSIndexPath indexPathForRow:indexPath.row+1
inSection:indexPath.section];
[self.prefTableView scrollToRowAtIndexPath:nextIndexPath
atScrollPosition:UITableViewScrollPositionTop
animated:YES];
//[self.prefTableView selectRowAtIndexPath:nextIndexPath
// animated:YES
// scrollPosition:UITableViewScrollPositionMiddle];
if ([[self.prefTableView indexPathsForVisibleRows] containsObject:indexPath] == YES) {
[[self.prefTableView viewWithTag:tagBeingEdited] becomeFirstResponder];
}
} else {
isEditing = NO;
}
return NO;
}
내보기 결코 스크롤 : 여기 내가 사용하는 코드입니다. 또는 수동으로보기를 스크롤 한 경우 맨 위로 이동합니다. 왜?
참고 : 나는 scrollToRowAtIndexPath 및 selectRowAtIndexPath 중 하나만 사용합니다. 나는 처음에 그 중 하나를 시도한 이후로 그 둘을 거기에 두었습니다.
인가? 대신에 UITableViewController를 하위 클래스 화하면 잘 작동하는 키보드 + 테이블에 대한 지원이 향상됩니다. 예를 들어, 당신을 위해 UITableView의 크기 조정을 처리 할 것입니다. – occulus
그것은 UITableViewController의 하위 클래스입니다. bahaviour는 지금과 같았다. 나는 다른 힌트 후에 그것을 UIViewController로 바꿨다. @interface의 PreferencesController : –
Arne
의 UIViewController 내가 조금 더 노력 이상의 행을 추가하고, 자신의 선택을 보여 세포를 활성화 이것은 내보기 컨트롤러의 선언입니다. 선택이 올바르게 진행되지만 뷰는 거의 임의로 스크롤됩니다. – Arne