First, the scene of crash
When Uiimagepickercontroller is used in the program, if you run the app on iphone6s, the program crash when you forcetouch a picture with the following crash message:
* Terminating app due to uncaught exception ' nsinvalidargumentexception ', Reason: ' +[nsobject previewingcontext: Viewcontrollerforlocation:]: Unrecognized selector sent to class 0x19f678020 '
The reason for this crash is probably a bug in Apple's own SDK, which we can learn about on the Apple website. https://forums.developer.apple.com/thread/21932 because as long as the controller is using a Uiimagepickercontroller, When we forcetouch the view that chooses the picture, we will crash.
Second, the problem of the solution
We can download this tool class from http://download.csdn.net/detail/smiling8866/9367050, and then in-(BOOL) Application: (UIApplication ) Application didfinishlaunchingwithoptions: (nsdictionary ) The Msdpreventimagepickercrashon3dtouch () method is called in the Launchoptions method to resolve the above crash.
Third, the matters needing attention
- When introducing the above tool class in the program, Ken can compile the arm64 error, most likely the suffix name of the tool file is incorrect. Because the code in the tool class is mostly C + +, the suffix name should be changed to. mm;
- At compile time, be sure to remove all breakpoints in the program, otherwise the code will always be stuck in the code of the try catch that section of exception handling.
- Note that the 3DTouch feature is only supported in iphone6s and later versions, and Xcode uses 7.0 and later versions, so the use of the lower version of Xcode is compiled and meaningless.
Resolution of the crash problem caused by 3DTouch when using Uiimagepickercontroller-standby