相机模式下的 UIImagePickerController 被“卡住”快门关闭时
有时,在内存不足的情况下,我使用的 UIImagePickerController 在快门关闭时会“卡住”。一般来说,当这个时候,WatchDog 已经准备好抛弃其他后台应用程序,因此在一两秒内低内存情况就会结束,但 UIImagePicker 控制器仍然卡住。
是否有其他人遇到过这种情况并实施了任何类型的解决方法,或者找到了一种方法来检测选择器何时处于这种状态,以便可以将其删除并放置一个新的位置。
想法/想法/解决方案??
Occasionally in low-memory conditions the UIImagePickerController I use gets 'stuck' with the shutter closed. Generally when this the WatchDog is allready jettisoning other background apps so within a second or two the low memory condition is over, yet the UIImagePicker controller is still stuck.
Has anyone else encountered this and implemented any sort of workaround or found a way to detect when the picker is in this state, so that it can be removed and a new one put in its place.
Thoughts / Ideas / Solutions??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在启动 UIImagePicker 之前,您是否尝试过使用 malloc() 分配(然后释放)一兆字节或两兆字节的内存?或者在您的应用程序中稍早声明它,然后在您想要显示选择器时释放它。
我想您应该能够通过在仪器内运行您的应用程序来大致了解 UIImagePicker 成功运行所需的内存量。
虽然不理想,但它应该会导致其他应用程序提前收到内存警告,因此 UIImagePicker 应该有足够的内存来运行。
Have you tried allocating (and then freeing) a megabyte or two of memory using malloc() before starting the UIImagePicker? Or claim it slightly earlier in your app, and then release it when you want to show the picker.
I guess you should be able to see roughly the amount of memory UIImagePicker needs to run successfully by running your app inside of instruments.
Whilst not ideal, it should cause other apps to be given memory warnings earlier on and hence the UIImagePicker should then have enough memory to run.
这也是相机应用程序的已知行为。我想除了在启动之前释放尽可能多的内存之外,您无法对其执行任何操作。您可以自己发出内存警告,以便每个应用程序都会收到它并开始释放内存,但我不知道如何做到这一点。我开始调查自己发送通知(UIApplicationDidReceiveMemoryWarningNotification),但没有成功。我想我们需要沿着通知发送一个对象来定义警告级别,但我真的不确定。
That's a known behavior of the camera application too. I guess you can't do anything to it except freeing as much memory as you can before starting it. You could raise a memoryWarning yourself so every application will receive it and start freeing memory but I have no idea how I can do that. I started investigate sending the notification myself (UIApplicationDidReceiveMemoryWarningNotification) without success. I guess we need to send an object along the notification to define the warning level but I'm really not sure.