iOS7.0ではXcode5でビルドするとUITextViewのカーソルがキーボードの下に隠れる場合があります。
この問題を解決する方法を発見しました。タイミング依存なのがなんですが、UITextViewのサブクラスを作る必要がないのが良いところです。
iOS7.1で何もしなくても解決されることを望みます。
ObjectiveC
@interface ViewController : UIViewController <UITextViewDelegate>
@end
@implementation ViewController
-(void) scrollToVisible:(UITextView *)textView
{
if ([textView isFirstResponder] && textView.selectedTextRange.end) {
CGRect caretRect = [textView caretRectForPosition:textView.selectedTextRange.end];
[textView scrollRectToVisible:caretRect animated:YES];
}
}
-(void) textViewDidBeginEditing:(UITextView *)textView
{
[self performSelector:@selector(scrollToVisible:) withObject:textView afterDelay:0.3];
}
- (void) textViewDidChangeSelection:(UITextView *)textView
{
[self performSelector:@selector(scrollToVisible:) withObject:textView afterDelay:0.1];
}
-(void) textViewDidChange:(UITextView *)textView
{
[self performSelector:@selector(scrollToVisible:) withObject:textView afterDelay:0.2];
}
@end