ios - Kal Calender Disappears when clicked Tab -


when click tab bar holds kal calendar calendar disappears:

enter image description here

this code in viewwillappear:

-(void)viewwillappear:(bool)animated {     [super viewwillappear:animated];     kalviewcontroller *calendar = [[kalviewcontroller alloc] init];     [self.navigationcontroller pushviewcontroller:calendar animated:yes];     calendar.datasource = self;     calendar.delegate = self;     [calendar reloaddata];     self.tabbarcontroller.delegate = self; } 

i have method:

-(void)tabbarcontroller:(uitabbarcontroller *)tabbarcontroller didselectviewcontroller:(uiviewcontroller *)viewcontroller {      [self viewwillappear:yes];      //even when comment out line problem stays! } 

if need more infomation ask.

edit:

enter image description here

you using tab bar controller improperly. indeed, should populate controllers (either in interface builder or setting tab bar controller's controllers property) , let job.

on coin, note viewwillappear can called multiple times, last place want allocate new controller. if have overridden viewwillappear in order controller show when s view displayed not correct approach.

edit:

if create ui programmatically, these steps should follow in application:didfinishlaunching: setup rootviewcontroller:

firstviewcontroller *fistvc = ... secondviewcontroller *secondvc = ... thirdviewcontroller *thirdvc = ...  nsarray *viewcontrollers = [[nsarray alloc] initwithobjects:fistvc, secondvc, thirdvc, nil];  self.tabcontroller = [[uitabbarcontroller alloc] init]; [self.tabcontroller setviewcontrollers:viewcontrollers animated:yes];  self.window.rootviewcontroller = self.tabcontroller; 

if build ui in interface builder, same graphically, cannot reproduce here.

in case, hope snippet clarifies way tab bar controller works: instantiate of controllers, put them in array, pass array tab bar controller. no need instantiate anymore tabbed controllers (neither in viewwillappear nor in viewdidload)...


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -