ios - Presenting an alert from a view controller that has closed -
i have objectve c ios application in attempting show uialertcontroller, uiviewcontroller in process of closing. have tried adding common workaround in appdelegate
:
- (uiviewcontroller *)currenttopviewcontroller { uiviewcontroller *topvc = [[[[uiapplication sharedapplication] delegate] window] rootviewcontroller]; while (topvc.presentedviewcontroller) { topvc = topvc.presentedviewcontroller; } return topvc; }
called with:
[appdelegate.currenttopviewcontroller presentviewcontroller:alert animated:yes completion:nil];
however error still appearing:
warning: attempt present uialertcontroller on myviewcontroller view not in window hierarchy!
can advise?
if want display alert upon closing viewcontroller, can implement dismiss completion block , display there. example:
[self dismissviewcontrolleranimated:yes completion:^(void) { // uialertcontroller code here }];
Comments
Post a Comment