Presentation view controller modulo from action sheet delegate in iOS8 - iOS10

So, I noticed that in iOS8 beta 3 ( Update : still happening in iOS 10) on the iPad, when you try to present a view controller from the UIActionSheet delegate UIActionSheet , nothing "happens and the log message is displayed on the debug console, stating that the presentation was attempted during the transition of the warning controller:

 Warning: Attempt to present <UIViewController: 0x...> on <ViewController: 0x...> which is already presenting <UIAlertController: 0x...> 
+57
ios uikit uialertcontroller uiactionsheet
Jul 20 '14 at 20:52
source share
9 answers

Update: In the iOS 9 SDK, the UIActionSheet deprecated, so don't expect this problem to be fixed. It is best to use the UIAlertController whenever possible.




The problem seems to be related to replacing Apple with the UIAlertController inside to implement the functionality of alert views and action sheets. This issue is mainly addressed on the iPad and action sheets, because on the iPad action sheets are presented as popover in a specific view, and what Apple does is move the responder chain until it finds a view controller and calls presentViewController:animated:completion: with internal UIAlertController The problem on the iPhone is also obvious with warnings, because there Apple actually creates a separate window, an empty view controller and represents an internal UIAlertController on top of it, so it does not seem to interfere with another view.

I opened an error report for this problem: rdar: // 17742017 . Please duplicate it and tell Apple that this is a problem.

As a workaround, I recommend deferring the presentation to the next runloop using the following method:

 dispatch_async(dispatch_get_main_queue(), ^ { [self presentViewController:vc animated:YES completion:nil]; }); 
+135
Jul 20 '14 at 20:52
source share
— -

You can try to do your job (view view controller) in

 - (void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {} 

instead

 - (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {} 

as @LeoNatan said, "The problem seems to be related to replacing Apple with the use of the UIAlertController internal interface to implement alert functionality and action sheets." Therefore, you must wait until the action sheet is rejected, and then submit the desired controller.

The @LeoNatan solution simply blocks the user interface in the main thread, so it will also ensure that the view controller is presented after the action sheet is rejected.

+31
Sep 30 '14 at 2:06
source share

Unfortunately, this code does not work for me, I think, because my problem did not call the presentController method directly, but in the prepareForSegue method, therefore

 [segue destinationViewController] 

I noticed that if segue is "push", everything works correctly, but if it is "modal", just in ipad, I got this error.

Then I found a new option in the storyboard in the segue panel, and I circumvented my problem by selecting “Current Context” for the “Presentation” option

I hope this will be useful for someone else ... here is a screenshot about the option

enter image description here

+4
Sep 24 '14 at 9:39
source share

I had the same problem. I created a separate window for warnings and action tables in my appdelegate and presented warnings on it. It worked for me!

  self.alertWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.alertWindow.backgroundColor = [UIColor clearColor]; UIViewController *dummy = [[UIViewController alloc] init]; [self.alertWindow setRootViewController:dummy]; 

You can imagine how:

 [[myAppDelegate appDelegate].alertWindow makeKeyAndVisible]; [[myAppDelegate appDelegate].alertWindow.rootViewController presentViewController:alertController animated:YES completion:nil]; 
+2
Feb 09 '15 at 9:37
source share

Issue

 [self.navigationController dismissViewControllerAnimated:YES completion:nil]; 

on

 - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 

before trying to imagine a different mode of operation for me.

+1
Oct. 15 '14 at 3:33
source share

use

 - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex 

instead

 - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 

The action view is presented above the current VC, so this causes a warning / error. when Dismiss was called, the kind of action was already fired, so no problem at all :))

+1
Feb 04 '15 at 13:27
source share

I installed it in Swift 3 with the following code

  DispatchQueue.main.async { self.present(alertController, animated: true, completion: nil) } 
+1
Apr 21 '17 at 14:37
source share

Try

 [[NSOperationQueue mainQueue] addOperationWithBlock:^{ // action sheet presentation // or modal view controller presentation // or alert view presentation }]; 
0
Feb 11 '15 at 13:22
source share

In iOS 8, Apple uses the UIAlertController internal interface to implement the functionality of blogs and action sheets. Therefore, when you want to show a UIViewController modally after displaying a UIActionSheet or UIAlertView in the delegation method, for example

 (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 

and

 (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 

you must first fire the UIAlertController as follows:

 if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) { UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; [vc dismissViewControllerAnimated:NO completion:^{ }]; } 

Now you can introduce the modal UIViewController in iOS 8.

0
Feb 20 '15 at
source share



All Articles