I am facing a crash on following statement in IOS 5. This seems to work in other IOS versions. The scenario is that I am presenting a view as a modal from a viewController and then on tap on cancel button I call the below code to dismiss the self as modal view. This work fine till here.
But after 30 seconds I redraw my view by calling the server to get latest data and after view is drawn again when I tap on “Cancel” button I get a crash — Only on IOS 5.0. Any clue for this?
[self dismissModalViewControllerAnimated:YES];
Error:
Single stepping until exit from function -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:]
This is the screenshot of error in the thread trace:

If the administrator allows me to add a new comment (my last one was removed) I could explain what was happening in my case.
There is something in this link that I recognise I was doing wrong.
The problem comes when presenting the view, however the application crashes when dismissing it. Now, what is the problem? In my code I was presenting the view immediately next to a popToRootViewControllerAnimated: call. As you can see in link I have just pasted, iOS5 seems to have some restriction when presenting modal views. As a summary of the link, you cannot make presentModalViewController:animated: before viewDidLoad and viewWillAppear: are finished:
That was exactly my fault. What can you do if this is happening to you? You can present the modal view after a delay. So, instead of using this:
you should use this:
(I suppose a performSelector:afterDelay: also works)…
and make sure
delayInSecondsis big enough to let viewDidLoad and viewWillAppear finish. Sorry if this not very accurate and elegant, but at least it works.Regards.