我正在使用调用viewDidAppear
上的presentModal
方法
[[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!
警告会告诉您,出了什么问题。为了避免此警告,您可以使用UINavigationController的delegate
属性并实现
- (void)navigationController:(UINavigationController *)navigationController
didShowViewController:(UIViewController *)viewController
animated:(BOOL)animated