2017-03-16 33 views
0

我試圖在我的iOS 10 ipad應用程序中居中彈出。iOS 10 popoverPresentationController在prepareForSegue中爲零

我在故事板中創建了從一個視圖到另一個視圖的popover segue。在prepareForSegue

enter image description here

然後:我已經設置了 '之類的' SEGUE以 '酥料餅'

if ([[segue identifier] isEqualToString:@"PopoverSegue"]) { 
    UIPopoverPresentationController *popoverController = segue.destinationViewController.popoverPresentationController; 
    popoverController.sourceView = self.view; 
    popoverController.sourceRect = self.view.bounds; 
} 

然而popoverController爲零。環顧四周,它看起來像別人已經成功這樣做:

How to change the size of a popover

任何想法,爲什麼酥料餅SEGUE在故事板創建的時候,我不能讓popoverPresentationController在prepareForSegue的聯繫呢?

+0

我不知道你的架構,但它可能是缺少navaigationController。試試這個:segue.destinationViewController.navigationController.popoverPresentationController或segue.destinationViewController.popoverPresentationController.navigationController – Ramis

+0

我沒有在導航控制器中嵌入我的viewcontroller。所以沒有導航控制器。據我所知popoverPresentationController應該在嵌入popover的視圖中。爲了好玩,我在導航控制器中嵌入了我的視圖,以查看是否有所作爲,但事實並非如此。 iOS 10中的錯誤?在iOS 10中不支持? – lostintranslation

回答

0

Your segue kind is Popover。如果您將其更改爲作爲彈出窗口存在,那麼您應該在destinationViewController.popoverPresentationController屬性中看到值。您可能需要明確啓用故事板屬性中的特徵變體以彈出式菜單的形式顯示爲選項。