开发者

Is addsubview on iOS thread safe?

I'm using Apple's Page Control sample and my UIScrollview isn't smooth when scrolling. I'm thinking about using GCD. I believe that all my code is thread safe, e开发者_开发百科xcept for my last line which is [self.scrollView addSubview:myView].

The docs that I read all mentions that UIKit is not thread safe, but the examples given are always related to setting values such as self.myLabel.text = @"some text".

Is addSubview thread safe?


All interface manipulation should be done in main thread! In other case you'll probably would gain painful headache.


You should call all UIKit methods on the main thread, this includes -[UIView addSubview:].


It is my understanding that this would not be thread-safe. To my knowledge, the only thing you can do with UIKit that is thread-safe is creating instances of UIImage (but not adding them to a view).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜