UIPopoverPresentationController给我黑屏

3
我正在开发一个应用程序,需要显示带有图像的弹出窗口,我使用了UIPopoverController,但是在iOS8上,这个类已经被弃用,Apple建议使用UIPopoverPresentationController代替,但是当我尝试显示弹出窗口时,屏幕变成了黑色。你能帮我吗?谢谢。
以下是我尝试将名为“popVC”的视图控制器作为弹出窗口打开的代码。 *vernazaImagenDetalle是UIViewController子类
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

1个回答

0
对我来说,在presentationControllerDelegate中添加以下内容有效 -
  func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
    return .None;
  }
  func adaptivePresentationStyleForPresentationController(controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
    return .None;
  }

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