开发者

How to improve the performance of [NSString drawInRect:withFont]?

I'm implementing an app for a micro blog service, something similar to twitter. I've done everything I know to improve the performance, including using drawRect instead of sub view based architecture.

After run the app with Instrument, I found that [NSString drawInRect:withFont] takes up more than 50% time, especially during the first time scrolling, after which I can scroll quite smoothly. Although [NSString drawInRect:withFont] still takes up the most of time, it's significantly smoother, and no obvious lag can be noticed.

I don't know if the layers are cached or something, b开发者_StackOverflowut with break point and NSLog I can see that drawRect and drawInRect are still called. Then why it only lags at the first time of scrolling?

The twitter's official app really has excellent performance. Is there any insider that can tell me some practical tricks?


Actually, Loren Bricher, the developer behind the Twitter app wrote a blog post about just this.

You can check it out here: http://blog.atebits.com/2008/12/fast-scrolling-in-tweetie-with-uitableview

(Tweetie is the name of the official Twitter app before it was bought by Twitter, in case you didn't know.)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜