2014-09-29 204 views
2

我正在开发一个应用程序,我需要显示与图像的弹出窗口,我用UIPopoverController,现在在iOS8上这个类已被弃用,Apple建议使用UIPopoverPresentationController来代替,但我得到一个黑色屏幕,当我尝试显示popover。你可以帮我吗?谢谢。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

回答

0

对我来说,加入以下presentationControllerDelegate工作 -

func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle { 
    return .None; 
    } 
    func adaptivePresentationStyleForPresentationController(controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle { 
    return .None; 
    }