Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple Modal-view Transitions Crash App
    text
    copied!<p>I would like to present multiple modal views in sequence (e.g. show confirmation page after selecting a picture from image picker). My problem is that the animation of dismissal and presenting in subsequent steps without delay always crashes the app with an <code>EXC_BAD_ACCESS</code>.</p> <p>I assume that the problem is that <code>CoreAnimation</code> does not distinguish between the two transitions and cannot detect properly whether the first one has ended or not.</p> <p>My work around so far is to introduce a 1 section delay which seems to solve the problem. However, I think that this makes the code a bit fragile. Is there another workaround?</p> <p>Is this a bug in UIKit and should I submit a bug report?</p> <p><b>Sample code</b></p> <p>Here is a simple case that reproduce the crash:</p> <ol> <li><p>Create a new View-based project with the following class as the implementation of the main controller</p></li> <li><p>Hit 'cancel' when image picker view is presented</p></li> </ol> <p>Expected behavior: the picker view is dismissed and presented again due to the subsequent call in <code>viewDidAppear</code>.</p> <p>Actual behavior: It crashes with the stack trace presented below.</p> <p>Code:</p> <pre><code> #import "SampleViewController.h" @implementation SampleViewController - (void)showModal { UIImagePickerController *picker = [[UIImagePickerController alloc] init]; [self presentModalViewController:picker animated:YES]; // [picker release]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [self showModal]; // this line crashes the app // the following works as desired // [self performSelector:@selector(showModal) withObject:nil afterDelay:1]; } @end </code></pre> <p>Crash Stack trace:</p> <pre> #0 0x30b43212 in -[UIWindowController transitionViewDidComplete:fromView:toView:] #1 0x3095828e in -[UITransitionView notifyDidCompleteTransition:] #2 0x3091af0d in -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] #3 0x3091ad7c in -[UIViewAnimationState animationDidStop:finished:] #4 0x00b54331 in run_animation_callbacks #5 0x00b54109 in CA::timer_callback #6 0x302454a0 in CFRunLoopRunSpecific #7 0x30244628 in CFRunLoopRunInMode #8 0x32044c31 in GSEventRunModal #9 0x32044cf6 in GSEventRun #10 0x309021ee in UIApplicationMain #11 0x00002794 in main at main.m:14 </pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload