开发者

iPad: UIImage imageWithContentsOfFile performance problems

I need to display a 20 x 15 grid of images on an iPad. Each image is 50px x 50 px.

I am using [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"name" ofType:@"png"]] to do this but am running into performance issues. The application lags heavily. There are 14 different types of images, all 50x50 in png format.

Is there a method I could use to increase the performance?

Update: I tried using the solution found at the following link; this he开发者_开发百科lped some, but did not completely solve the problem. Hopefully, it helps others. http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/


imageNamed will cache the image so will be faster on the second use etc. If that doesn't help then you can pre-load the images if memory is not too badly affected and then just swap them out of an NSArray or NSMutableArray for example.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜