从UIPopoverController解除PresentsViewController

时间:2014-08-01 04:39:44

标签: ios objective-c uipopovercontroller presentviewcontroller

来自popoverview的PresentedViewController,这是我使用

的代码
SearchPropertyVC *SearchPropertyVC *centerViewController = (SearchPropertyVC *)[board instantiateViewControllerWithIdentifier:@"vcSearchPropertyID"];
UINavigationController *ConDetVC = [[UINavigationController alloc] initWithRootViewController:centerViewController];
ConDetVC.modalPresentationStyle = UIModalPresentationPageSheet;
ConDetVC.modalPresentationStyle = UIModalPresentationFormSheet;
ConDetVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

[self presentViewController:ConDetVC animated:YES completion:nil];
ConDetVC.view.superview.bounds = CGRectMake(0, 0, 700, 670);

控制器打开正常,当我试图关闭控制器时,我收到此警告

"警告:正在进行演示或解雇时尝试从视图控制器中解除!"

之后,如果我点击任何按钮,应用程序将崩溃。

这是我用来解散视图的代码

[self dismissViewControllerAnimated:YES completion:nil];

[self dismissViewControllerAnimated:YES completion:^{
             [(UINavigationController *)self.presentingViewController popToRootViewControllerAnimated:YES];
         }];

if (![self.presentedViewController isBeingDismissed])
            [self dismissViewControllerAnimated:YES completion:nil];

当我尝试关闭popover视图本身时会收到相同的警告

2 个答案:

答案 0 :(得分:0)

在第一行正确的下方。

 SearchPropertyVC *SearchPropertyVC *centerViewController = (SearchPropertyVC *)[board instantiateViewControllerWithIdentifier:@"vcSearchPropertyID"];

 SearchPropertyVC *searchPropertyVC = (SearchPropertyVC *)[board instantiateViewControllerWithIdentifier:@"vcSearchPropertyID"];

选择任何一种演示风格

 ConDetVC.modalPresentationStyle = UIModalPresentationPageSheet;
 ConDetVC.modalPresentationStyle = UIModalPresentationFormSheet;

页面表或表单。

当您尝试呈现时,请使用您想要呈现的视图控制器的对象。

 [self presentViewController:ConDetVC animated:YES completion:nil]; 

当它被解雇时,只需写下来,

 [self dismissViewControllerAnimated:YES completion:^{
         // write you code here
     }];

答案 1 :(得分:0)

这将对您有所帮助:

 [self.presentedViewController dismissViewControllerAnimated: YES completion:^(void) {
             [self presentViewController:myController animated:YES completion:nil];
    }];