I think your view is not updated, because you never exit recursion, and therefore the loop cycle never ends the iteration. A better solution than a recursive method would be to use NSTimer
, which disables your function once, say, 1/30 or 1/60 of a second, using +[NSTimer timerWithTimeInterval:target:selector:userInfo:repeats:]
.
If you want to preserve the recursive structure that you are here, you can use -[NSObject performSelector:withObject:afterDelay:]
to call your function after a delay. Just use something like 1 / 60.0 for the delay and pack any information you need into a dictionary or array to go to the withObject:
parameter.
Any of these methods will register your method with a run loop, which will be called later. This allows you to start the start cycle of a new iteration, which means that user interface updates can occur.
Edit: if your line does not change during this animation, calculate the text size once and save it in the instance variable. Calculating the row size during each call to your method can be expensive.
source share