- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我的模型来自 Core Data。我的 bean 将图像作为 NSData 存储在模型中。
要显示我的图像,我需要做:
[UIImage imageWithData:bean.imageData]
如果我到处都这样做可以吗?我的意思是,从 View #1 开始,我通过创建 [UIImage imageWithData:] 来显示图像,然后我继续 View #2,在那里我需要显示相同的图像,但我只在两个 View 之间传递 bean,所以我重新创建了 UIImage使用 [UIImage imageWithData]。
我想知道如果我这样做是否需要太多的 CPU 或内存...我需要自己管理缓存吗?我认为这可能是 CoreData 非常常见的用例,那么是否有一种通用的模式来处理这个问题?
最佳答案
imageWithData 不会缓存您的图像(根据文档,唯一要缓存的 UIImage 方法是 imageNamed)
Here is an algorithm不过,用于缓存图像。
关于ios - 调用 [UIImage imageWithData :xxx] multiple times,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18604853/
我有一个带有 DetailViewController 的典型“向下钻取”风格的应用程序其中包括 UIImageView , UIWebView ,还有一些 UILabel s。问题是 imageVi
我有两个需要相互关联的 UIImage,但是我不知道如何计算我设置的 UIImage 大小与我在 Base64 数据中接收的图像的实际大小的比例。 目前我这样做时没有计算原始 imageview 的大
这个问题在这里已经有了答案: Loading/Downloading image from URL on Swift (39 个答案) 关闭 7 年前。 我通过将图像数据传递给它来快速创建一个 UI
我需要从字节数组创建 UIImage。现在我创建了字节数组: image = CGImageCreateWithImageInRect(aux.CGImage, imageRect); context
我正在 iOS 中的 UIImage 上工作,发现两种方法可以完成相同的工作 - (id)initWithData:(NSData *)data // (instance metho
我有一个将图像存储为 NSData 的应用程序在核心数据中。 当需要时,我使用 imageView.image = [UIImage imageWithData:] 将这些图像加载到我的 View 中
我正在使用最新的 SDK 开发 iOS 5.0+ 应用程序。 在我的应用程序上,我有一些 C++ 图像识别软件,我正在尝试保存此 C++ 函数识别的图像。 我有这个数组来存储识别的图像: int _d
我是 Android 开发的新手,所以如果这是一个愚蠢的问题,请原谅我。基本上我有一个 iPhone 应用程序,它将 UIImage 压缩到 NSData,使用 UIImageJPEGRepresen
我的一个 NSManagedObjects 中有这段代码: if (self.tempImageStorage) { return self.tempImageStorage; } else
我正在从网络上下载一些图像并将其保存到我的应用程序的私有(private)存储中,以便在表格 View 单元格中显示。我有它的工作,但不幸的是,除非我使用: [UIImage imageNamed:
在我的自定义 tableViewCell 中,我有一个填充整个单元格的 imageView(不是 tableViewCell 的默认 imageView)。它是在 IB 中(通过代码)使用 conte
我想从文件系统将一些图像加载到我的应用程序中。有两种简单的方法可以做到这一点: [UIImage imageNamed:fullFileName] 或者: NSString *fileLocation
我想将图像加载到我的 MAC OS 桌面应用程序中。我找到了大量关于如何在移动 iOS 上执行此操作的文档,但由于没有 UIImage(imageWithData),因此如何在桌面应用程序上加载图像。
下面的代码没有显示从网上下载并写入我的应用程序文档目录的图像。我查看了iphone的模拟器文档目录,下载的文件是存在的。但图像不显示。 当尝试使用 UIImage *imgBack = [UIImag
我的模型来自 Core Data。我的 bean 将图像作为 NSData 存储在模型中。 要显示我的图像,我需要做: [UIImage imageWithData:bean.imageData] 如
我正在将一些图像保存到我的应用程序中的 SQLite 数据库中。我使用图形化的 SQLite 客户端访问了数据库,它正确地保存了我的图像的二进制文件。问题在于从数据库中检索它。这是它的样子: 保存 -
我编写了一个 iOS 方法来将选定的图像上传到网络服务器,因此: NSData *imageData = UIImagePNGRepresentation(imageView.image); NSSt
我正在尝试从一个 uiimage 检索图像数据,对其进行修改,然后从中创建一个新的 uiimage。首先,我尝试在不进行任何修改的情况下复制数据来了解基础知识 - 但失败了(UIImage +imag
我有一个带有属性的 View Controller galleryCache当使用 GCD 和 imageWithData: 下载图像时图像已使用 key 成功添加到缓存中。但是,当 View Con
为了防止我的应用程序滞后,我尝试压缩大于 1 MB 的图像(主要用于从 iphone 的普通相机拍摄的照片。 UIImage *image = [info objectForKey:UIImagePi
我是一名优秀的程序员,十分优秀!