我想創建一個彈出式窗口,當我呈現視圖控制器時,背景始終爲純黑色,並且大小爲全屏。如何在iOS9中呈現PopOver
我似乎無法找出什麼是錯的,這裏是代碼,我有
@IBAction func distancePopOver(sender : UIBarButtonItem){
//a UIViewController that I created in the storyboard
let controller = storyboard!.instantiateViewControllerWithIdentifier("distancePopOver")
controller.modalPresentationStyle= UIModalPresentationSTyle.PopOver
controller.preferredContentSize = CGSizeMake(200,30)
self.presentViewController(controller, animated: true, completion: nil)
//Configure the Popover presentation controller
let popController = (controller.popoverPresentationController)!
popController.permittedArrowDirections = UIPopoverArrowDirection.Down
popController.barButtonItem = sender
popController.delegate = self
}
每當我點擊的UIBarButtonItem,它提出了在全屏視圖,但它不應該是我在第5行中指定的尺寸?
最後一點與adaptivePresentationStyleForPresentationController(_:traitCollection :)爲我做了。謝謝 –
它在iPad上運行良好,但不在iPhone中運行。 – Satyam