3

i am developing an app where i need to show popovers with an image, i used UIPopoverController, now on iOS8 this class is deprecated and Apple suggest to use UIPopoverPresentationController instead, but i get a black screen when i try to show the popover. Can you help me? Thanks.

Here is the code where i try to open the View Controller called "popVC" as a popover. *vernazaImagenDetalle is a UIViewController subclass

vernazaImagenDetalle *vc =

[self.storyboard instantiateViewControllerWithIdentifier:@"popVC"];

vc.modalPresentationStyle = UIModalPresentationPopover;

[self presentViewController:vc animated: YES completion: nil];



UIButton *boton=(UIButton*)sender;

NSLog(@"tag %ld",(long)boton.tag);



UIPopoverPresentationController *presentationController =

[vc popoverPresentationController];

presentationController.permittedArrowDirections =0;

presentationController.sourceView =boton;

presentationController.sourceRect = CGRectMake(self.stringContenido.frame.size.width/2,(250+self.stringContenido.contentOffset.y),1,1);

vernazaImagenDetalle class.h vernazaImagenDetalle class.m

The VC in the storyboard (Main)

the screen when i click the button to show the popover

Victor Pinto
  • 177
  • 1
  • 9

1 Answers1

0

For me adding the following to presentationControllerDelegate worked -

  func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
    return .None;
  }
  func adaptivePresentationStyleForPresentationController(controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
    return .None;
  }
adarsh
  • 1,070
  • 1
  • 7
  • 17