The application freezes in the implementation of the "look and pop" in the iPhone 6s

I applied peek and pop in my application and it works great. But with continuous testing 7-8 times, the application depends on the view. The only option I have is to kill the application and run it again. Please let me know the reason for the freeze. I used the following code to view and view in my project:

var isPresentedBy3Dtouch: Bool = false var passedDetails:DetailModel! func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? { guard let indexPath = tableView?.indexPathForRowAtPoint(location) else { return nil } guard let cell = tableView?.cellForRowAtIndexPath(indexPath) else { return nil } guard let detailViewController = self.storyboard?.instantiateViewControllerWithIdentifier("Navigation") as? UINavigationController else { return nil } (detailViewController.topViewController as! DetailViewController).passedDetails = self.customerLists[indexPath.row] (detailViewController.topViewController as! DetailViewController).isPresentedBy3Dtouch = true detailVC.preferredContentSize = CGSize(width: 0.0, height: 480.0) previewingContext.sourceRect = cell.frame return detailVC } func previewingContext(previewingContext: UIViewControllerPreviewing, commitViewController viewControllerToCommit :UIViewController) { showViewController(viewControllerToCommit, sender: self) } 
+7
ios iphone swift peek-pop
source share
3 answers

This is a problem that I brought to engineers at Apple a month ago, and there is no answer to them yet. If you are debugging the hierarchy of views, you will notice that the UITransitionView level is the topmost view and it is not deleted. This is what makes the application freeze. In fact, the applicationโ€™s functionality is not frozen - it still works as expected, but the user interface is stuck. Here is my original post here in the Stack Overflow section: Force Touch Force animation freezes

+2
source share

I found the cause of this error.

If your view manager needs to support force preview, you need to register this vc using a delegate by calling the - (id <UIViewControllerPreviewing>)registerForPreviewingWithDelegate:(id<UIViewControllerPreviewingDelegate>)delegate sourceView:(UIView *)sourceView NS_AVAILABLE_IOS(9_0); for this.

I just call this function twice twice (once in the superclass viewDidLoad() , once in sub vc), and when I delete once in my sub vc, this error is fixed! Amazing ...

This is still Apple's error, as it does not make any difference to this. However, I wish this answer helps developers who have the same problem with me.

+1
source share

I found another possible reason for this error.

In viewControllerForLocation, I created an instance of the view controller to show ...

 func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? { let vc = VCImageFullScreen.loadView() return vc } 

... but this ViewController had the wrong super call in its DidAppear view:

  class VCImageFullScreen : UIViewController { override func viewDidAppear(_ animated: Bool) { super.viewWillAppear(animated) //BUG --> should be super.view**Did**Appear(animated) ... } } 

After fixing this problem, everything worked as expected.

+1
source share

All Articles