UIImage的2种加载方式的区别

方式一:有缓存(图片所占用得内存会一直停留在程序中)
UIImage *image = [UIImage imageNamed:filename];

方式二:无缓存(图片所占用的内存会在一些特定操作后被清除)
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle pathForResource:filename ofType:nil];
UIImage *image = [UIImage imageWithContentsOfFile:path];
path是图片的全路径

猜你喜欢

转载自invictus-fang.iteye.com/blog/2143003
今日推荐