jaredsinclair / JTSImageViewController

An interactive iOS image viewer that does it all: double tap to zoom, flick to dismiss, et cetera.
MIT License
32 stars 11 forks source link

3D Touch UIViewController Previewing #97

Closed andreyrd closed 8 years ago

andreyrd commented 8 years ago

Hey I'm trying to use this with 3D touch view controller previewing with a previewing delegate like:

    func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {

        let imageInfo = JTSImageInfo()
        imageInfo.image = image
        imageInfo.referenceRect = imageView.frame
        imageInfo.referenceView = imageView

        let controller = JTSImageViewController(
            imageInfo: imageInfo,
            mode: .Image,
            backgroundStyle: .Blurred
        )
        return controller
    }

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

        presentingViewController?.presentViewController(
            viewControllerToCommit,
            animated: true,
            completion: nil
        )
    }

The preview shows as a black box, and the controller opens as a black screen. Then when you swipe on the screen the app crashes with:

'NSInvalidArgumentException', reason: 'View item (<UIImageView: 0x147c2ced0; frame = (0 0; 375 249.023); clipsToBounds = YES; opaque = NO; layer = <CALayer: 0x14ba47c80>>) should be a descendant of reference view in <UIDynamicAnimator: 0x14ba1bec0> Stopped (0.000000s) in <UIScrollView: 0x14715e600> {{0, 0}, {375, 667}}'

I'm thinking it has something to do with the animations JTSImageViewController does conflicting with those from the 3D touch preview?