Ios UITextView,编辑时滚动?

Ios UITextView,编辑时滚动?,ios,cocoa-touch,keyboard,uitextview,Ios,Cocoa Touch,Keyboard,Uitextview,我有一个大的UITextView,几乎全屏。如果我点击它,键盘就会弹出,我可以编辑文本。但是,我输入的时间越长,文本最终会在视图中的键盘后面运行。我再也看不见我在打什么了 你是怎么处理的?您必须跟踪光标位置并手动滚动视图吗?您需要使用以下代码根据文本范围(或根据键入)向下滚动文本视图 希望,这将帮助您…我想您必须根据键盘显示/隐藏来调整UITextView的大小。所以键盘不会在你的文本视图上。这是示例代码 - (void)viewDidLoad { [[NSNotificationCen

我有一个大的
UITextView
,几乎全屏。如果我点击它,键盘就会弹出,我可以编辑文本。但是,我输入的时间越长,文本最终会在视图中的键盘后面运行。我再也看不见我在打什么了


你是怎么处理的?您必须跟踪光标位置并手动滚动视图吗?

您需要使用以下代码根据文本范围(或根据键入)向下滚动文本视图


希望,这将帮助您…

我想您必须根据键盘显示/隐藏来调整UITextView的大小。所以键盘不会在你的文本视图上。这是示例代码

- (void)viewDidLoad
{
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillShow:)
                                                 name:UIKeyboardWillShowNotification
                                               object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillHide:)
                                                 name:UIKeyboardWillHideNotification
                                               object:nil];
}

- (void)keyboardWillShow:(NSNotification *)notification
{
    [UIView beginAnimations:nil context:nil];
    CGRect endRect = [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
    CGRect newRect = YOUT_TEXT_VIEW.frame;
    //Down size your text view
    newRect.size.height -= endRect.size.height;
    YOUT_TEXT_VIEW.frame = newRect;
    [UIView commitAnimations];
}

- (void)keyboardWillHide:(NSNotification *)notification
{
    ... // Resize your textview when keyboard is going to hide
}

TPKeyboardAvoiding是一个很好的工具,它可以处理所有滚动操作,为您避免使用键盘/非常方便,强烈推荐。请参阅:

Thanx以获得回复。但我得到了我想做的链接。下面的链接很好。@user1328096供子孙后代使用。您能将问题的解决方案作为正确答案写下来吗?(别忘了接受一些答案!)@adamjansch:完全同意。为什么人们会问他们是否已经有了解决方案。?我想。仅针对“增加堆栈溢出的堆栈”不,亲爱的,我在过去2小时内一直在搜索此问题。但我无法找到最佳解决方案。但当我发布问题时。5分钟后,我得到了链接。这就是为什么我发布链接以帮助其他人。抱歉,亲爱的,如果你介意的话……哇,多棒的键盘啊!
- (void)viewDidLoad
{
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillShow:)
                                                 name:UIKeyboardWillShowNotification
                                               object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillHide:)
                                                 name:UIKeyboardWillHideNotification
                                               object:nil];
}

- (void)keyboardWillShow:(NSNotification *)notification
{
    [UIView beginAnimations:nil context:nil];
    CGRect endRect = [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
    CGRect newRect = YOUT_TEXT_VIEW.frame;
    //Down size your text view
    newRect.size.height -= endRect.size.height;
    YOUT_TEXT_VIEW.frame = newRect;
    [UIView commitAnimations];
}

- (void)keyboardWillHide:(NSNotification *)notification
{
    ... // Resize your textview when keyboard is going to hide
}