ios - View Controller Pushed from other view controller never loads -
in tab based application, have view controller uitableview
created in storyboard. when swipe on 1 of images in table, i'd current view controller (secondviewcontroller
) load xib file(speciesviewcontroller.xib
) "take app" new view. far, didselectrowatindexpath
called on swiping, xib file never loaded.
- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { speciesviewcontroller* speciescontroller = [[[speciesviewcontroller alloc]initwithnibname:@"speciesviewcontroller" bundle:nil] autorelease]; // speciesviewcontroller* speciescontroller = [[speciesviewcontroller alloc] init]; species *thespecies = [fetchedresultscontroller objectatindexpath:indexpath]; speciescontroller.thespecies = thespecies; switch (sortbysegmentedcontrol.selectedsegmentindex) { case ksortbycommonnamefirst: speciescontroller.title = [thespecies commonnamefirstlast]; break; case ksortbycommonnamelast: speciescontroller.title = [thespecies commonnamelastfirst]; break; case ksortbyscientificname: speciescontroller.title = [[nsstring alloc] initwithformat:@"%@%@", [thespecies.scientificname substringtoindex:1], [[thespecies.scientificname substringfromindex:1] lowercasestring]]; break; default: break; } speciescontroller.hidesbottombarwhenpushed = yes; self.navigationitem.backbarbuttonitem = [[uibarbuttonitem alloc] initwithtitle:@"back" style:uibarbuttonitemstyleplain target:nil action:nil]; //// store current index path viewdidappear animation. //// self->currentselectedindexpath = indexpath; [self.navigationcontroller pushviewcontroller:speciescontroller animated:yes]; }
the speciesviewcontroller
nib has speciesviewcontroller
custom class in attributes inspector. reason, expect viewdidload, or other method speciesviewcontroller.m
, called when pushviewcontroller:speciescontroller
.
many posts issues loading nib have mistakes of initwithnibname
vs initwithcoder
. however, believe correctly using initwithnibname
because doing view controller.
i appreciate help! thank much!
i think should not use autorelease,this should work if nib name correct
speciesviewcontroller* speciescontroller = [[speciesviewcontroller alloc]initwithnibname:@"speciesviewcontroller" bundle:nil] ;
and think should first embed tableviewcontroller inside navigationcontroller, if have not done guess self.navigationcontrolller nil currently.
you can present view controller this
[self presentviewcontroller:speciescontroller animated:yes completion:nil];
hope helps
Comments
Post a Comment