2016-04-22 33 views
1

我嘗試使用彈出窗口顯示視圖。由於UIPopoverController不能在IPhone上使用,我使用WEPopoverController。WEPopoverController顯示視圖,第二次關閉後

我的代碼:

UIViewController *controller = [[UIStoryboard storyboardWithName:@"Main" bundle:nil]instantiateViewControllerWithIdentifier:@"GetDateController"]; 
controller.modalPresentationStyle = UIModalPresentationPopover; 
WEPopoverController *pop = [[WEPopoverController alloc] initWithContentViewController:controller]; 
pop.delegate = self; 
CGRect screen = [[UIScreen mainScreen]bounds]; 
CGRect r = CGRectMake(8, 8, screen.size.width-8, 57); 
pop.popoverContentSize = r.size; 
[pop presentPopoverFromRect:CGRectMake(200, 100, 0, 0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 

當我啓動該程序,我看到過的窗口彈出,並立即消失。 當我在iPhone上使用UIPopoverController程序崩潰時,在iPad上一切正常。

我需要用WEPopoverController使它工作嗎?

Alexander。

+0

現在popover可以在iPhone啓動iOS8的iPhone中使用。您可以使用 - (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller返回UIModalPresentationNone; }在iPhone中顯示相同的彈出窗口 –

回答

1

這是因爲視圖控制器不擁有您創建的彈出窗口,沒有強引用,並且ARC發現彈窗的引用計數爲0,並立即釋放它。你所需要做的就是在創建之後將彈出窗口作爲視圖控制器的屬性。

+0

非常感謝您的配合! 我做WEPopoverController作爲我的MasterViewController的屬性。我應該做UIViewController也作爲MasterViewController的屬性? – alisichkin

+0

不,因爲popover擁有它 – MudOnTire

相關問題