【发布时间】:2011-04-27 17:26:33
【问题描述】:
我有一个覆盖整个屏幕的 UITextview。为了补偿键盘,我添加了这个处理程序:
- (void)keyboardWasShown:(NSNotification*)aNotification{
// Resize for the stupid keyboard
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
CGRect rect = _textView.frame;
rect.size.height -= kbSize.height;
_textView.frame = rect;
CGPoint p = [_textView contentOffset];
[_textView setContentOffset:p animated:NO];
[_textView scrollRangeToVisible:NSMakeRange([_textView.text length], 0)];
}
这在纵向模式下很有效,但在横向模式下视图完全消失了。有没有更优雅的解决方案来处理这个问题?我阅读了 apples keyboard management 的文档,但它没有太多可以解决方向问题的内容。
【问题讨论】:
标签: iphone objective-c ios ipad uitextview