ios7 - UITextView not scrolling in a loop -


i have uitextview updated in loop. text appended end of text view @ every loop. textview updates not scroll show end of text view.

the method use append text is:

- (void)appendtext:(nsstring*)text totextview:(uitextview *)textview {   dispatch_async(dispatch_get_main_queue(), ^{     nsattributedstring* attr = [[nsattributedstring alloc] initwithstring:text];     [[textview textstorage] appendattributedstring:attr];     [textview scrollrangetovisible:nsmakerange([[textview text] length], 0)];     [textview setneedsdisplay];     [textview setneedslayout];   }); } 

the textview updates text continues show top.

this compiled ios 7+ only.

other answers on not solving this.

any clues?

you might want see this: https://github.com/steipete/pspdftextview

basically, need give uitextview time calculation. don't scroll immediately, wait few moments (~0.2sec) before trying scroll text view. and, avoid having blank line @ end of text. needed add @ least 1 character in last line. (space works me)


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -