Skip to content

Instantly share code, notes, and snippets.

@ceekay1991
ceekay1991 / gist:be467831f35b76a4bb61
Created March 17, 2016 14:04 — forked from jonklein/gist:b85b7835d4dc615a9593
iOS crash when presenting view controller after dialog display
// the fact that alertView is retained here seems important -- does not reproduce otherwise.
self.alertView = [[UIAlertView alloc] initWithTitle: @"OK" message: @"OK" delegate: nil cancelButtonTitle: @"Cancel" otherButtonTitles: nil];
[self.alertView show];
// White the dialog is open, present a modal view controller. In a real-world scenario, this is actually
// occurring when the view controller is presented in response to alertView:clickedButtonAtIndex:, but
// for this example, we'll do it automatically.
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
UIViewController *controller = [[UIViewController alloc] initWithNibName: nil bundle: nil];
controller.view = [[UIView alloc] initWithFrame: CGRectMake(0, 0, 320, 480)];