Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UITextView滚动问题_Iphone - Fatal编程技术网

Iphone UITextView滚动问题

Iphone UITextView滚动问题,iphone,Iphone,我已经完成了90%的滚动,这只是我无法让它工作的一个例子。如果textView.contentSize.height小于textView高度,但大于键盘向上时可见的空间,则无法手动将所需内容滚动到视图中,特别是如果用户希望返回并编辑其中一行 我在键入时使用以下命令来定位面纱。当文本结束时,它会自动将光标保持在视图中,但也允许手动滚动 -(void)textViewDidChange:(UITextView *)textView { NSRange range = textView.select

我已经完成了90%的滚动,这只是我无法让它工作的一个例子。如果textView.contentSize.height小于textView高度,但大于键盘向上时可见的空间,则无法手动将所需内容滚动到视图中,特别是如果用户希望返回并编辑其中一行

我在键入时使用以下命令来定位面纱。当文本结束时,它会自动将光标保持在视图中,但也允许手动滚动

-(void)textViewDidChange:(UITextView *)textView {

NSRange range = textView.selectedRange;
if (range.location == textView.text.length) 
{
    int height = textView.contentSize.height;
    if (height > 180) 
    {
        [textView setContentOffset:CGPointMake(0, height -180)];
    }
}
}

然后,在编辑完成后,我使用以下命令定位textView

    if (!editing) {
    [notesText setContentOffset:CGPointMake(0, 0)];}