我正在使用高清图像,经过一段时间后我的记忆已满,我用UIImage *image = [UIImage imageNamed:@""];
更新了我的图像,是否在内存方面是正确的?
答案 0 :(得分:3)
[UIImage imageNamed:]
缓存图像。请尝试使用[UIImage imageWithData:]
。
答案 1 :(得分:2)
是的,它正在发挥作用。 在我们的应用程序中,我们与另一种方法比较
1)
[self.view setBackgroundColor:[UIColor colorWithPatternImage:
[UIImage imageWithContentsOfFile:[
[NSBundle mainBundle] pathForResource:@"mainScreenBackground" ofType:@"png"]]]];
占用内存使用量22 mb
2)
[self.view setBackgroundColor:[UIColor colorWithPatternImage:
[UIImage imageWithData:
[NSData ] pathForResource:@"mainScreenBackground" ofType:@"png"]]]];
占用内存使用量15mb
非常感谢