ios - unwind segue works with button but not programmatically - why? -
well i'm not having start objective c , xcode - second time i've had come here in 1 simple project - embarrassing!
my master (squad) view controller loads detail (pilot) view controller, in turn loads third view controller (selectnewpilot) modal segue. works fine. if press cancel button on selectnewpilot (modal) view unwinds pilot (detail) view controller. in pilot view controller have code:
- (ibaction)unwindtolist:(uistoryboardsegue *)segue { uiviewcontroller *source = [segue sourceviewcontroller]; if([source iskindofclass:[mz0selectnewpilotviewcontroller class]]) { if ([(mz0selectnewpilotviewcontroller *)source pilot] == nil) { nslog(@"we cancelled selecting new pilot"); [self performseguewithidentifier:@"unwind" sender:self]; } else { nslog(@"we selected %@", [[(mz0selectnewpilotviewcontroller *)source pilot] name]); } } } so if nothing selected in selectnewpilot (modal) controller (i.e. cancelled) pilot controller automatically unwinds further squad (master) controller. produces following error:
2014-03-13 00:45:07.578 squad builder[3149:70b] *** assertion failure in -[uinavigationcontroller poptoviewcontroller:transition:], /sourcecache/uikit_sim/uikit-2935.120.3/uinavigationcontroller.m:4886 2014-03-13 00:45:07.581 squad builder[3149:70b] *** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'tried pop view controller doesn't exist.' *** first throw call stack: ( 0 corefoundation 0x01b629e4 __exceptionpreprocess + 180 1 libobjc.a.dylib 0x018e28e5 objc_exception_throw + 44 2 corefoundation 0x01b62848 +[nsexception raise:format:arguments:] + 136 3 foundation 0x014c20de -[nsassertionhandler handlefailureinmethod:object:file:linenumber:description:] + 116 4 uikit 0x006edbe0 -[uinavigationcontroller poptoviewcontroller:transition:] + 302 5 uikit 0x006edaad -[uinavigationcontroller poptoviewcontroller:animated:] + 56 6 uikit 0x006e633f __90-[uinavigationcontroller segueforunwindingtoviewcontroller:fromviewcontroller:identifier:]_block_invoke + 142 7 uikit 0x00b197ac -[uistoryboardsegue perform] + 35 8 uikit 0x00c7d623 -[uistoryboardunwindseguetemplate _perform:] + 554 9 uikit 0x00b090b7 -[uistoryboardseguetemplate perform:] + 115 10 libobjc.a.dylib 0x018f4880 -[nsobject performselector:withobject:withobject:] + 77 11 uikit 0x005a67f9 -[uiapplication sendaction:to:from:forevent:] + 108 12 uikit 0x008938bf -[uibarbuttonitem(uiinternal) _sendaction:withevent:] + 139 13 libobjc.a.dylib 0x018f4880 -[nsobject performselector:withobject:withobject:] + 77 14 uikit 0x005a67f9 -[uiapplication sendaction:to:from:forevent:] + 108 15 uikit 0x005a6785 -[uiapplication sendaction:totarget:fromsender:forevent:] + 61 16 uikit 0x006a7fe1 -[uicontrol sendaction:to:forevent:] + 66 17 uikit 0x006a83d6 -[uicontrol _sendactionsforevents:withevent:] + 577 18 uikit 0x006a7653 -[uicontrol touchesended:withevent:] + 641 19 uikit 0x005e621d -[uiwindow _sendtouchesforevent:] + 852 20 uikit 0x005e6e11 -[uiwindow sendevent:] + 1117 21 uikit 0x005b8a32 -[uiapplication sendevent:] + 242 22 uikit 0x005a2793 _uiapplicationhandleeventqueue + 11455 23 corefoundation 0x01aebf7f __cfrunloop_is_calling_out_to_a_source0_perform_function__ + 15 24 corefoundation 0x01aeb90b __cfrunloopdosources0 + 235 25 corefoundation 0x01b089ae __cfrunlooprun + 910 26 corefoundation 0x01b081d3 cfrunlooprunspecific + 467 27 corefoundation 0x01b07feb cfrunloopruninmode + 123 28 graphicsservices 0x03a175ee gseventrunmodal + 192 29 graphicsservices 0x03a1742b gseventrun + 104 30 uikit 0x005a53db uiapplicationmain + 1225 31 squad builder 0x0000a6bd main + 141 32 libdyld.dylib 0x021ad701 start + 1 ) if comment out line [self performseguewithidentifier:@"unwind" sender:self]; works fine, have press cancel on pilot controller squad controller. question why unwind segue (from pilot squad) work when use button trigger it, not when called programmatically (it's same unwind segue, applied identifier 1 cancel button uses)?
the unwindtolist method in squad controller completes, i'm not sure being called causes error. making segue try pop something? set in storyboard somewhere?
the unwindtolist method squad controller below (both nslog outputs appear before error):
- (ibaction)unwindtolist:(uistoryboardsegue *)segue { nslog(@"unwound squad"); mz0pilotviewcontroller *source = [segue sourceviewcontroller]; mz0card *pilot = [source pilot]; if ([pilot iskindofclass:[mz0card class]]) { nslog(@"adding new pilot: %@", [pilot name]); if(![_testdata containsobject:pilot]) { [_testdata addobject:pilot]; [self.tableview reloaddata]; } } nslog(@"finished unwinding squad"); } update: i've noticed error before starts printing output (and final error):
unbalanced calls begin/end appearance transitions <mz0squadviewcontroller: 0x8dc8720> is because it's trying unwind quickly? there way can tell not unwind pilot squad until first unwind (from selectnewpilot pilot) complete?
Comments
Post a Comment