0
상단에 도구 모음이 있고 그 안에 텍스트 필드가있는 표보기가있는보기가 있습니다. 테이블보기 맨 아래에있는 텍스트 필드를 편집하려면 편집중인 텍스트 필드가 키보드에 숨겨져 있습니다 (테이블보기가 위로 스크롤되지 않으므로). http://cocoawithlove.com/2008/10/sliding-uitextfields-around-to-avoid.html을 구현하려고했지만 내 전체보기가 위로 이동 (도구 모음 및 테이블보기)되는 동안 전체 시간 동안보기 상단에 toobar를 표시하려고합니다. 나는 이런 식으로 뭔가에 언급 된 코드를 수정 :보기 상단에있는 도구 모음으로 표보기를 스크롤하는 방법
- (void)textFieldDidBeginEditing:(UITextField *)textField {
CGRect textFieldRect = [tableView.window convertRect:textField.bounds fromView:textField];
CGRect viewRect = [tableView.window convertRect:tmpTableView.bounds fromView:tableView];
CGFloat midline = textFieldRect.origin.y + 0.5 * textFieldRect.size.height;
CGFloat numerator = midline - viewRect.origin.y - MINIMUM_SCROLL_FRACTION * viewRect.size.height;
CGFloat denominator = (MAXIMUM_SCROLL_FRACTION - MINIMUM_SCROLL_FRACTION) * viewRect.size.height;
CGFloat heightFraction = numerator/denominator;
if (heightFraction < 0.0) {
heightFraction = 0.0;
} else if (heightFraction > 1.0) {
heightFraction = 1.0;
}
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
animatedDistance = floor(PORTRAIT_KEYBOARD_HEIGHT * heightFraction);
} else {
animatedDistance = floor(LANDSCAPE_KEYBOARD_HEIGHT * heightFraction);
}
CGRect viewFrame = tableView.frame;
viewFrame.origin.y -= animatedDistance;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:KEYBOARD_ANIMATION_DURATION];
[tableView setFrame:viewFrame];
[UIView commitAnimations];
}
과이 상단에 내 도구 모음 숙박이 만든
- (void)textFieldDidEndEditing:(UITextField *)textField {
CGRect viewFrame = tableView.frame;
viewFrame.origin.y += animatedDistance;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:KEYBOARD_ANIMATION_DURATION];
[tableView setFrame:viewFrame];
[UIView commitAnimations];
}
하지만 불행히도 테이블 뷰 도구 모음을 오버레이와 도구 모음이 표시되지 않습니다.
어떻게 해결할 수 있습니까?
하지만 키보드 위로 텍스트 필드를 편집하려면 테이블보기를 스크롤하고 싶습니다. 테이블보기의 간단한 크기 조정으로 샘 기능을 사용할 수 있습니까? – Jakub
크기를 변경 한 후에는'scrollToRowAtIndexPath : atScrollPosition : animated :'를 사용하여 보이는 영역으로 셀을 스크롤 할 수 있습니다. –
어떤 셀을 보이는 영역으로 스크롤 할 수 있다면 크기를 조정하는 용도는 무엇입니까? 나는 테이블 뷰가 정상적인 크기 일 때도 scrool 수 있습니다. btw. 만들 수 없습니다. scrollToRowAtIndexPath : atScrollPosition : animated : work. 나는 간단하게 시도했다 : NSIndexPath * ip = [NSIndexPath indexPathForRow : 1 inSection : 1]; [self.settingsTableView scrollToRowAtIndexPath : ip atScrollPosition : UITableViewScrollPositionTop animated : 아니요]; 두 번째 행을 두 번째 행에서 스크롤하여 (키보드가 작동하는지 확인) 키보드 아래에 숨겨져 있습니다. – Jakub