In general [UIApplication Sharedapplication].keywindow.rootviewcontroller is initialized in Appdelegate, and the entire application is not changed during the run.
So in many places need to use the Presentmodelviewcontroller method, with this rootviewcontroller is very convenient, because it is equivalent to a global variable, no need to apply, release.
However, I found in the use of the Rootviewcontroller was changed to nil case.
The analysis found that when Uialertview called the Show method, Rootviewcontroller would be changed to nil, and then changed back when it dismiss. And I need the user to click on the button on the Alertview and then do
The operation of the Presentmodelviewcontroller.
Workaround:
Do not use the Alertview delegate in the
-(void) Alertview:clickedbuttonatindex:
Method
Instead, use:
-(void) Alertview:diddismisswithbuttonatindex:
Method!
[UIApplication Sharedapplication].keywindow.rootviewcontroller