【发布时间】:2010-06-15 21:21:56
【问题描述】:
我有一个 UIScrollView 并且在屏幕的下部是一个文本字段。当我选择文本字段时,键盘显示在文本字段上方。 UIScrollView 中的 UIView 不够大,无法向上滚动并为键盘腾出一些空间。所以我尝试以编程方式放大 UIView。 这就是我所拥有的:
- (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;
}
谢谢。
【问题讨论】:
标签: iphone uiscrollview