ios - UINavigation's dismissViewControllerAnimated method called when closing UIAlertController -


i've got problem understanding, how ios view controllers , alert controllers work in specific case:

i have custom uinavigationcontroller in there uiviewcontroller. navigation controller has overridden dismissviewcontrolleranimated:completion method. uiviewcontroller present new uialertcontroller. point user clicks button in alert, works fine. however, strange part is, custom uinavigationcontroller's dismissviewcontrolleranimated:completion method being called (i don't want that, if possible...)

the alert presented in regular manner (from uiviewcontroller within uinavigationcontroller):

uialertcontroller *alert = [uialertcontroller alertcontrollerwithtitle:title message:message preferredstyle:uialertcontrollerstylealert];  uialertaction *okaction = [uialertaction actionwithtitle:@"yep" style:uialertactionstyledefault handler:^(uialertaction * _nonnull action) {     [self takeorder:data]; }];  uialertaction *cancelaction = [uialertaction actionwithtitle:@"nope" style:uialertactionstylecancel handler:^(uialertaction * _nonnull action) {  }];  [confirmorderacceptalert addaction:okaction]; [confirmorderacceptalert addaction:cancelaction];  [self presentviewcontroller:alert animated:yes completion:nil]; 

is there option prevent behavior? why happen in first place?

edit: code dismissviewcontrolleranimated:completion:

- (void)dismissviewcontrolleranimated:(bool)flag completion:(void (^)(void))completion {     self.isheroenabled = no;     [super dismissviewcontrolleranimated:flag completion:completion]; } 

i'm using hero library animate transitions, case?

as subclassing uinavigationcontroller, call dismissviewcontrolleranimated:completion.

to avoid disturbing library code, check specific viewcontroller types.

eg:

- (void)dismissviewcontrolleranimated:(bool)flag completion:(void (^)(void))completion {     if(![self.visibleviewcontroller iskindofclass:[uialertcontroller class]]){             self.isheroenabled = no;     }     [super dismissviewcontrolleranimated:flag completion:completion]; } 

Comments