objective-c 内存友好的背景图像方式

标签 objective-c memory-leaks background-image memory-warning

我有一个 ipad 应用程序(>30 个 View /页面)每个 View 都有独特的背景。

问题: 什么是设置背景的最佳方式(内存友好)

有没有比添加:uiimageview "backgroundView"作为 subview 更好的方法?

版本 1:

[[UIImage alloc] initWithData:imageData];

视网膜开关似乎有问题

版本 2:

self.layer.contents = (id)image.CGImage;

版本 3:

UIImage* image = [UIImage imageWithContentsOfFile:fileLocation];

版本 2 似乎工作正常。也许有人告诉我最好的方法是什么,为什么 ;)

谢谢 亚历克斯

最佳答案

CGImage 与 retina 有问题 ... version3。最适合内存!

关于objective-c 内存友好的背景图像方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10584217/

相关文章:

ios - 'SwiftClass' 不可用 : cannot find Swift declaration for this class - iOS Simulator only

objective-c - View 与 cocoa 中的文件所有者没有连接

qt - 如何解决 QPixmap::fromImage 内存泄漏?

memory-leaks - 内存泄漏和操作系统

css - Bootstrap 轮播作为网站背景

python - 查找背景的最佳方法-图像处理Python

ios - Swift - 使用哪些类型? NSString 或字符串

iphone - FlowCover 问题 Objective-C

c++ - 在删除指向动态分配对象的指针 vector 中的元素之前,我需要做什么?

Android 模拟器浏览器 - 背景图像缺失