1
我有一個UIScrollView,在屏幕的下半部分是一個文本框。當我選擇文本框時,鍵盤顯示在文本框上方。 UIScrollView中的UIView不夠大,無法向上滾動併爲鍵盤釋放一些空間。所以我試圖通過編程擴大UIView。 這就是我得到的:UIScrollView滾動問題
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
UIScrollView *scrollView = (UIScrollView *)[[self view] viewWithTag: 2];
UIView *contentview = [[self view] viewWithTag: 3];
CGRect rect = contentview.frame;
rect.size.height = 650;
contentview.frame = rect;
[scrollView setContentSize: contentview.frame.size];
//first try
rect.origin.y = 450;
[scrollView scrollRectToVisible: rect animated: YES];
//second try
CGPoint point = CGPointMake(0, 450);
[scrollView setContentOffset: point animated: YES];
return YES;
}
謝謝。