objective c - Confirmation Popup when poppingViewController in iOS -


i have uitableviewcontroller loads tabbarviewcontroller on selecting row.

the user can change information on screen, , hit back button in navigation controller. tabbarviewcontroller of kind show (e.g. push) via storyboard segue.

if user changes on screen , hits button, want able display alert asking if want leave screen. or if switch tabs.

i used this question reference can't seem hook right.

if @ below screenshot can see tabs broken various items.

enter image description here

the "vehicle view controller" monitor changes using bool didmakechanges gets set true when edits made.

in viewdidload in vehicleviewcontroller

- (void)viewdidload {     [super viewdidload];      didmakechanges = false;      //here holding reference tabviewcontoller     self.mvc = (mastertabviewcontroller*)self.tabbarcontroller;       uibarbuttonitem *bbtnback = [[uibarbuttonitem alloc] initwithtitle:@"go" style:uibarbuttonitemstylebordered target:self action:@selector(goback:)];      [self.navigationitem setbackbarbuttonitem: bbtnback];  }  - (void)goback:(uibarbuttonitem *)sender {     if (didmakechanges) {          uialertview *alert = [[uialertview alloc] initwithtitle:@"changes made"                                                         message:@"discard vehicle changes without saving?"                                                        delegate:self                                               cancelbuttontitle:@"no"                                               otherbuttontitles:@"yes", nil];         [alert show];     } else {         [self.navigationcontroller popviewcontrolleranimated:yes];     } }  - (void)alertview:(uialertview *)alertview clickedbuttonatindex:(nsinteger)buttonindex {     switch(buttonindex) {         case 0: //"no" pressed             break;         case 1: //"yes" pressed             [self.navigationcontroller popviewcontrolleranimated:yes];             break;     } } 


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -