警告:在调用通知时尝试显示模态

时间:2014-10-09 13:26:45

标签: ios iphone

我在presentModal上使用:

调用viewDidAppear方法
[[NSNotificationCenter defaultCenter] addObserver:self         
                                             selector:@selector(presentModal)         
                                                 name:@"xxxxxxx"         
                                               object:nil];

-(void)presentModal 
{
    PickerModalViewController *pickerModalViewController = [Appdelegate.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@"PickerModalViewController"];

    pickerType = 2;
    pickerModalViewController.choices = self.localArray;
    pickerModalViewController.buttonTag = pickerType;

    pickerModalViewController.delegate = self;
    self.pickerPresenter = self;

    if (self.pickerPresenter) {
        [self.pickerPresenter presentViewController:pickerModalViewController animated:YES completion:nil];
    }
}

当呈现选择器时,它在设备和模拟器中给我一个警告

警告:Attempt to present PickerModalViewController: 0x10ec7280 on UINavigationController: 0x90ad610 while a presentation is in progress!

1 个答案:

答案 0 :(得分:0)

警告告诉你,出了什么问题。 要避免此警告,您可以使用UINavigationController的delegate属性并实现

- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated