检查UIImageView的图像是否已更改
好的,所以我有一个问题,我需要检查用户是否更改了内部图像和 imageView。如果不是,那么应用程序不需要重新保存一堆东西,并且它被更改,那么它应该保存。所以基本上这只是为了优化代码,因为在保存时我将四个图像(loRes、loResThumb、hiRes 和 hiResthumb)写入磁盘,这需要一些时间。
我想我可以尝试通过在用户进入编辑模式时将图像保存为 NSDATA 来实现这一点,然后当用户退出时,检查并查看 UIIMageView 中包含的 NSDATA 是否与我之前临时保存的相同。这会起作用还是它们是更好的方法,例如检查 UIImagePicker 是否已被调用(并不一定意味着图像已更改,但至少比每次保存更接近)。
任何提示表示赞赏。谢谢!
Ok, so I have a problem where I need to check if the user has changed the image inside and imageView. If no then the app doesn't need to resave a bunch of stuff and it is changed then it should save. So bascically this is just to optimize the code since when saving I am writing four images (loRes, loResThumb, hiRes and hiResthumb) to disk and that takes a little while.
I thought I might try doing it by saving the image as NSDATA when the user enters edit mode and then when the users exits, check and see if the NSDATA contained in the UIIMageView is the same as the one I saved temporarily before. Would that work or is their a better way, like checking if the UIImagePicker has been called (doesn't necessarily mean the image is changed but at least it closer than just saving every time).
Any tips appreciated. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试创建 UIImageView 的子类,如果设置了
image
,则“标记”脏值。Try creating a subclass of UIImageView that 'tags' a dirty value if
image
is set.