开发者

UITextView Scrolling Problem

I have 90% of my scrolling worked out it's just one case where I cannot get it to work. If the textView.contentSize.height is smaller then the textView height but larger than the space visible with the keyboard up it is not possible to manually scroll the desired content into view, specifically if the user wants go back and edit one of the top lines.

I am using the following to position the veiw when typing. It automatically keeps the cursor in view when at the end of the text but allows manual scrolling also.

-(void)t开发者_JS百科extViewDidChange:(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)];
    }
}

}

Than I use the following to position the textView when editing is complete.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜