【问题标题】:scroll text in UITextView在 UITextView 中滚动文本
【发布时间】:2011-06-18 14:14:59
【问题描述】:

我有一个 UITextView:当我隐藏键盘时,我用这段代码返回到文本的起点

-(BOOL)textViewShouldBeginEditing:(UITextView *)textView {
    ...
    NSRange range = NSMakeRange(0,1);
    [note scrollRangeToVisible:range];
    return YES; 
}

但是我如何在书写时滚动文本,例如 4 行?所以不会覆盖键盘上的文字

谢谢大家

【问题讨论】:

    标签: objective-c xcode scroll uitextview


    【解决方案1】:

    您可以将 contentInset 设置为键盘的高度。

    收听UIKeyboardWillShowNotification 通知。实现这样的东西:

    CGFloat keyboardHeight = ... // The userInfo variable contains keyboard info.
    [textView setContentInsets:UIEdgeInsetsMake(0.0, 0.0, keyboardHeight, 0.0)];
    

    这将自动为您滚动文本视图。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多