iPhone 6s - iOS 9.1在[UICollectionViewController previewingContext:viewControllerForLocation:]上崩溃

6
这是一个相当混乱的堆栈跟踪,因为查看后,我唯一能想到的就是,iPhone 6s用户试图3D触摸某些东西,而我的手势识别器(在某个地方,我不知道是哪一个,因为它没有告诉我哪一行甚至是哪个控制器)不知道如何处理?我没有添加任何3D-touch手势识别器,也没有在任何地方实现3D-touch交互。
在此构建中,我针对iOS 8进行了定位,不幸的是我没有iPhone 6s可以测试,所以无法真正重现它。
关于可能导致它发生的想法,如何缩小何处/什么和如何复制以及如何处理异常?
Thread : Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x18586cf48 __exceptionPreprocess
1  libobjc.A.dylib                0x19ad17f80 objc_exception_throw
2  CoreFoundation                 0x185873b54 __CFExceptionProem
3  UIKit                          0x18b63438c -[UICollectionViewController previewingContext:viewControllerForLocation:]
4  UIKit                          0x18b187d7c -[_UIViewControllerPreviewSourceViewRecord previewInteractionController:viewControllerForPreviewingAtPosition:inView:presentingViewController:]
5  UIKit                          0x18b43cd4c -[UIPreviewInteractionController startInteractivePreviewAtLocation:inView:]
6  UIKit                          0x18b43d848 -[UIPreviewInteractionController startInteractivePreviewWithGestureRecognizer:]
7  UIKit                          0x18b43e8c0 -[UIPreviewInteractionController _handleRevealGesture:]
8  UIKit                          0x18b37b330 _UIGestureRecognizerSendTargetActions
9  UIKit                          0x18afa4b5c _UIGestureRecognizerSendActions
10 UIKit                          0x18ae3285c -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:]
11 UIKit                          0x18b37c70c ___UIGestureRecognizerUpdate_block_invoke898
12 UIKit                          0x18adf18b8 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks
13 UIKit                          0x18adee63c _UIGestureRecognizerUpdate
14 UIKit                          0x18ae306cc -[UIWindow _sendGesturesForEvent:]
15 UIKit                          0x18ae2fcc8 -[UIWindow sendEvent:]
16 UIKit                          0x18ae004a4 -[UIApplication sendEvent:]
17 UIKit                          0x18adfe76c _UIApplicationHandleEventQueue
18 CoreFoundation                 0x185824544 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
19 CoreFoundation                 0x185823fd8 __CFRunLoopDoSources0
20 CoreFoundation                 0x185821cd8 __CFRunLoopRun
21 CoreFoundation                 0x185750ca0 CFRunLoopRunSpecific
22 GraphicsServices               0x190cd4088 GSEventRunModal
23 UIKit                          0x18ae68ffc UIApplicationMain
24 XXXXXXXXXX                     0x10013739c main (main.m:16)
25 libdyld.dylib                  0x19b55a8b8 start
3个回答

6

PUPhotoGridViewController(用于UIImagePickerController)是一个简单的UICollectionViewController,您可以为未实现的方法编写扩展。

extension UICollectionViewController: UIViewControllerPreviewingDelegate {
    public func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
        return nil;
    }

    public func previewingContext(previewingContext: UIViewControllerPreviewing, commitViewController viewControllerToCommit: UIViewController) {

    }
}

Obj-C也怎么样? - brandonscript

5

您的应用程序中是否使用了UIImagePickerController?它与3D Touch存在已知问题:UIImagePickerController在力触下崩溃?

UIImagePickerController中进行力触操作似乎会使任何应用程序崩溃。我想我们必须等待苹果公司解决这个问题。


是的,我的研究得出了同样的结论。 - brandonscript
我的原始答案中有一个链接指向相同的问题,抱歉 :) 我在剪贴板中搞混了...现在已经修复了! - Vlas Voloshin
哦,等等,你实际上在你的问题中已经有了那个链接,而我没有注意到。这很尴尬!我想我刚刚确认了我也遇到了同样的问题 ¯\(ツ) - Vlas Voloshin
哈!我完全没有意识到那是同一个链接... ¯_(ツ)_/¯ - brandonscript

3

感谢 @Antigp 的答案

以下是 OC 版本:

头文件

@interface UICollectionViewController (FixCrash) <UIViewControllerPreviewingDelegate>
- (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location;
- (void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext
     commitViewController:(UIViewController *)viewControllerToCommit;
@end

实施

@implementation UICollectionViewController (FixCrash)
- (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location {
    return nil;
}
- (void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext
         commitViewController:(UIViewController *)viewControllerToCommit {
    return;
}
@end

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接