iPad warning:Attempt to present on xxxx which is already presenting (null)

这个问题网上也有很多的答案.我在这里分享下我详细过程.

设备: ipad pro

系统:iOS 10.3

相关代码 

这里使用actionSheet 创建活动卡<问题就出现在这>

iPad warning:Attempt to present <UIImagePickerController:xxxx > on xxxx which is already presenting (null)_第1张图片

...

iPad warning:Attempt to present <UIImagePickerController:xxxx > on xxxx which is already presenting (null)_第2张图片

// 这里 

iPad warning:Attempt to present <UIImagePickerController:xxxx > on xxxx which is already presenting (null)_第3张图片

正确的代码

__weak typedef(self)weakSelf = self;

if([[[UIDevicecurrentDevice]systemVersion]floatValue]>=8.0){

[[NSOperationQueuemainQueue]addOperationWithBlock:^{[selfpresentViewController:cameraUI animated:NO completion:nil];}];

}else{

[controller presentViewController:cameraUI animated:NO completion:nil];

}

原因分析:


iPad warning:Attempt to present <UIImagePickerController:xxxx > on xxxx which is already presenting (null)_第4张图片

提供答案的作者猜想,在ios 8 中, alert view 和 action sheet 实际上是以控制器的方式弹出的.所以,如果你从这个alert view 上弹出了一个响应控制器的话,这时,这个alert view 正在销毁, 而 你要弹出的控制器却整在被弹出. 操作冲突. 所以我延迟了 UIImagePickerController 的弹出, 直到runloop的下一次迭代.


笔者第一次写分享,写的不是很好,很多东西怕自己了解的不够深,造成误解.所以都是直接找的准确的解答来分享.

你可能感兴趣的:(iPad warning:Attempt to present on xxxx which is already presenting (null))