2014-09-29 251 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; 
    }