(iphone) showing activity indicator before heavy u

2019-07-20 10:22发布

I'm adding activity indicator view before doing some heavy ui updating (pushViewController takes a while to load view).

For some reason, indicator view doesn't appear until the new viewController is pushed.
(indicator view shows up right before the viewController push animation takes place,
although my intention was to show the indicator while a device takes long time before the animation)

Should I do something more than adding the indicator view as a subview?
I already tried [indicatorView'sSuperview setNeedsDisplay]; before the pushViewController call.

Thank you

1条回答
霸刀☆藐视天下
2楼-- · 2019-07-20 11:04

If the long-running operation is on the UI thread, this will block the entire UI, including the showing/animating of a spinner. If you can do some of that on a background thread you'll be better off. If the time is really being taken up by the view layout itself then you have a problem, but my guess is that most of the time is being taken up by non-UI activity. Feel free to post the code that's giving you trouble, as the problem is a little hard to diagnose without the code

查看更多
登录 后发表回答