UIImagePickerController在强制触摸时崩溃? [英] UIImagePickerController crashing on force touch?

查看:66
本文介绍了UIImagePickerController在强制触摸时崩溃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于iOS 9,如果我强行触摸显示的图像,我的所有 UIImagePickerControllers 现在都会崩溃。
错误信息是:

With iOS 9, all of my UIImagePickerControllers are now crashing if I do a force touch on the presented images. Error message is :

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSObject previewingContext:viewControllerForLocation:]: unrecognized selector sent to class 0x1a0752020'

我想这是一个Apple bug ,但有任何人可以解决?

I guess this is an Apple bug, but has anybody a work around ?

推荐答案

这是一个解决方法: https://gist.github.com/nolanw/bd0a8997632fe92a9f83 (警告:在私人课堂上调用一种方法,这可能会让你感到不安)。将这些文件粘贴到项目中,然后从某个地方调用 MSDPreventImagePickerCrashOn3DTouch (例如 -applicationDidFinishLaunching:... )。

Here's a workaround: https://gist.github.com/nolanw/bd0a8997632fe92a9f83 (warning: swizzles a method on a private class, which should probably make you queasy). Stick those files in your project, then call MSDPreventImagePickerCrashOn3DTouch from somewhere (e.g. -applicationDidFinishLaunching:…).

问题似乎是名为 PUPhotosGridViewController 的私有类调用 UIViewControllerPreviewing 超类上的方法,它没有实现该方法。解决方法调整了违规方法并尝试调用原始实现,但它吞下了异常,因此我们不会崩溃。希望通过这种方式,如果/当它得到修复,那么解决方法不会影响该修复。

The issue seems to be that a private class named PUPhotosGridViewController calls the UIViewControllerPreviewing method on its superclass, which does not implement that method. The workaround swizzles the offending method and tries to call the original implementation, but it swallows the exception so we don't crash. Hopefully, by doing it this way, if/when it gets fixed then the workaround doesn't affect that fix.

这篇关于UIImagePickerController在强制触摸时崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆