在iOS8中,弹出ActionSheet后选择其中一项,然后在ActionSheet的代理方法actionSheet(actionSheet:clickedButtonAtIndex:)中使用了performSegueWithIdentifier方法来跳转到下一个ViewController时,发现ViewController不但没有跳转,控制台却出现了以下警告:
-------UIGraphicsBeginImageContext
2021-08-16 13:42:30.977397+0800 ImageCroppingDemo[615:63044] [Presentation] Attempt to present <CXImageCropper: 0x10104acf0> on <ViewController: 0x10070b3d0> (from <ViewController: 0x10070b3d0>) which is already presenting <UIImagePickerController: 0x10181fe00>.
以下是解决办法:
1.跳转ViewController这种类型的代码最好写到actionSheet(actionSheet:, didDismissWithButtonIndex)方法中,保证ActionSheet消失后才跳转。
2.如果确实需要在actionSheet(actionSheet: clickedButtonAtIndex: )就跳转,那么可以做个延时,比如0.1秒之后再调用performSegueWithIdentifier方法。
[self dismissViewControllerAnimated:YES
completion:^{
ModalViewController *sampleView = [[ModalViewController alloc] init];
[self presentModalViewController:sampleView animated:YES];
}];
或
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker dismissViewControllerAnimated:YES completion:^{
//此方法之后再调用presentViewController [self presentViewController:vc animated:YES completion:nil];
[self operationImagePhotoInfo:info];
}];
}
网友评论