我有一个UITextView:当我隐藏键盘时,我会使用此代码返回文本的起点
-(BOOL)textViewShouldBeginEditing:(UITextView *)textView {
...
NSRange range = NSMakeRange(0,1);
[note scrollRangeToVisible:range];
return YES;
}
但是如何在写字时滚动文字,例如4行?所以不包括键盘上的文字
感谢所有
答案 0 :(得分:0)
您可以将contentInset设置为键盘的高度。
收听UIKeyboardWillShowNotification
通知。实现这样的东西:
CGFloat keyboardHeight = ... // The userInfo variable contains keyboard info.
[textView setContentInsets:UIEdgeInsetsMake(0.0, 0.0, keyboardHeight, 0.0)];
这将自动滚动文本视图。