2
我有一個覆蓋整個屏幕的UITextview。爲了彌補鍵盤添加此處理程序:鍵盤,方向和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)];
}
這工作在縱向模式花花公子,但鑑於在橫向模式完全在前看不見。有處理這個更優雅的解決方案嗎?我閱讀了蘋果keyboard management文檔,但它對於定位問題沒有多少幫助。