小图用 imageNamed: 大图用 dataWithContentsOfFile:options
2014-11-10 20:09
344 查看
1down voteaccepted | If you're loading images like:[UIImage imageNamed:@"myImage.png"]; Then the memory for this image will not deallocated, because imageNamed:cache the image. This method is useful for showing some small icons,avatars, etc. So, if you must show many big images, then use UIImage *myImage = [UIImage imageWithData:[[NSBundle mainBundle] pathForResource:@"myImage" ofType:@"png"]; This will not cache the image and memory will deallocated when retain count will equal to 0 for that object. Besides that, when you only push a view controller without pop it in future, then the view controller will never deallocated and will always take a place in memory until the app will not crashed/killed, or until the ViewController who holds that view controller will not deallocated. So, always make sure that you deallocated the viewController if there is no more need of it (i.e. pop it if it was pushed, or dismiss it in case if it was presented modally) and then show your next view controller.
| ||||
|
相关文章推荐
- imageNamed和dataWithContentsOfFile的区别(1)
- 大图用 imageWithContentsOfFile 小图用imageNamed
- iOS: NSData的方法dataWithContentsOfFile:options:error:
- imageNamed、imageWithContentsOfFile、imageWithData
- IOS如何选择图片加载方式:imageNamed和imageWithContentsOfFile的区别
- imageNamed与imageWithContentsOfFile加载图片的区别
- iOS 加载图片选择imageNamed 方法还是 imageWithContentsOfFile?
- ios 内存使用陷阱 和imageNamed 、imageWithContentsOfFile:
- iOS: NSData的方法initWithContentsOfFile:options:error:
- iOS imageNamed 与 imageWithContentsOfFile的区别
- imageNamed/ imageWithContentsOfFile /imageWithData 的区别
- iOS学习笔记-- 加载图片选择imageNamed 方法还是 imageWithContentsOfFile
- imageNamed 与 imageWithContentsOfFile的区别
- iOS: NSData的方法dataWithContentsOfFile:
- ios 内存使用陷阱 和imageNamed 、imageWithContentsOfFile:(转)
- UIImage加载图片选择imageNamed方法还是imageWithContentsOfFile?
- imageNamed/ imageWithContentsOfFile /imageWithData 的区别
- imageNamed 与 imageWithContentsOfFile的区别
- imageNamed 与 imageWithContentsOfFile的区别
- imageNamed 与 imageWithContentsOfFile的区别