[^sample_footnote]: this is a BUG that apple has quietly fixed in iOS9.3. Problem analysis

+[NSObject previewingContext:viewControllerForLocation:]: unrecognized selector sent to class 0x...... 
Copy the code

See method that previewingContext: viewControllerForLocation: this method is introduced in iOS 3 dtouch after some API function, but the company’s APP temporarily haven’t integrated 3 dtouch function, that’s strange. The crash was caused when users used 3DTouch to preview images while selecting images from the photo library. This should be iOS9 SDK a BUG. Forums.developer.apple.com/thread/2193… Apple’s official website http://stackoverflow.com/questions/33331758/uiimagepickercontroller-crashing-on-force-touch and SOF a description of the problem. At present, the triggered environment is:

Hardware: iPhone6S and iPhone6S Plus software: iOS9 and later

Now that the problem has been identified, it is easy to solve it. We can use Runtime to replace this method of the system without doing anything. Internet tools at https://gist.github.com/nolanw/bd0a8997632fe92a9f83 have a perfect solved the problem. The implementation principle is to use the Runtime implementation method replacement. Links can can’t open (over the wall), so I also put the library on https://github.com/Herb-Sun/MSDPreventImagePickerCrashOn3DTouch here convenient everyone download. # # # 3. Drag the class into the project using the

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Copy the code

Method calls MSDPreventImagePickerCrashOn3DTouch ().