4

Is there a way to know whether a UIViewController is currently being presented as a Peek Preview from a 3D touch? I don't want to create a completely new view controller but I would like to remove some controls that don't make sense when peeking.

The only thing I found out so far is only when the view controller is presented in "peek mode" the _modalSourceViewController property is not nil, but I don't know if I can trust that or how I can get to that property.

enter image description here

FrankWest
  • 365
  • 2
  • 10

1 Answers1

4

I just figured out that I could simply add a property to the viewController and set it when I instantiate it in the Peek delegate method and then handle the layout in the viewControllers implementation based on that property.

- (UIViewController *)previewingContext: (id<UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location {

  //... code to instantiate the corresponding viewController

  viewController.isPreviewed = YES;

}
FrankWest
  • 365
  • 2
  • 10