Scroll UITextView To Bottom

后端 未结 10 1701
误落风尘
误落风尘 2020-12-08 07:26

I am making a an app that has a UITextView and a button.

When I click the button some text will add in the UITextView.

But when c

10条回答
  •  佛祖请我去吃肉
    2020-12-08 08:05

    Try this if you have problem on iOS 7 or above. See this SO answer.

    - (void)scrollTextViewToBottom:(UITextView *)textView {
        NSRange range = NSMakeRange(textView.text.length, 0);
        [textView scrollRangeToVisible:range];
        // an iOS bug, see https://stackoverflow.com/a/20989956/971070
        [textView setScrollEnabled:NO];
        [textView setScrollEnabled:YES];
    }
    

提交回复
热议问题