dismissViewControllerAnimated crash in iOS8

2019-06-27 05:23发布

问题:

I have a application that work very well in iOS7.0/7.1 Since the last iOS update (8.0) the dismissViewControllerAnimated crash every time. Someone saw the same thing ?
I have a control this to call the second controller:

**detailViewController.delegate = self;
[self presentViewController:detailViewController animated:YES completion:nil];**

and in the close button I use this:

**// Do something with the sender if needed
[viewController dismissViewControllerAnimated:YES completion:NULL];**

I Used this (Remove view controller from another view controller) as a guide for implementation the "second" control but the crash appear again.

Any ideas ?

回答1:

I had a very similar issue when I was dismissing programmatically. (like when a delegate finished a process).

I used this and it worked perfectly:

if (![self isBeingDismissed]) {
    [self dismissViewControllerAnimated:YES completion:^{
    }];
}

It simply checks to see if it was already in the process of being dismissed. Hope this works for you!



回答2:

Check if there is any dealloc function defined as mentioned below. As it might led to Crash Sometimes.

- (void)dealloc {
      [_yourview release]; //don't do this
      [super dealloc];
}