objective c - Strange pushViewController behavior -
my app starts on loginviewcontroller
. login view has 1 button "register", code shown below. when app starts if click on register, nil happens. if login , logout, register button works properly.
what should problem happen?
appdelegate:
... - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { self.window = [[[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]] autorelease]; // override point customization after application launch. //load view controllers; self.vcclubs = [[[clubsviewcontroller alloc] init] autorelease]; self.vcparties = [[[partiesviewcontroller alloc] init] autorelease]; self.vceditprofile = [[[editprofileviewcontroller alloc] init] autorelease]; self.navclubs = [[[uinavigationcontroller alloc] initwithrootviewcontroller:self.vcclubs] autorelease]; self.navclubs.navigationbarhidden = yes; self.navparties = [[[uinavigationcontroller alloc] initwithrootviewcontroller:self.vcparties] autorelease]; self.navparties.navigationbarhidden = yes; // load login view uiviewcontroller *loginview = [[[loginviewcontroller alloc] init] autorelease]; self.window.rootviewcontroller = loginview; [self.window makekeyandvisible]; homecoming yes; } ... - (void)login { self.vcmenu = [[[menuviewcontroller alloc] init] autorelease]; self.vclocationmenu = [[[locationmenuviewcontroller alloc] init] autorelease]; self.maincontroller = [[[mainviewcontroller alloc] init] autorelease]; self.maincontroller.leftviewcontroller = self.vcmenu; self.maincontroller.rightviewcontroller = self.vclocationmenu; [self.maincontroller setmainviewcontroller:self.navparties]; [self.maincontroller showmainviewcontrolleranimated:yes]; self.window.rootviewcontroller = self.maincontroller; catransition *transition = [[[catransition alloc] init] autorelease]; transition.duration = 1; transition.type = kcatransitionfade; transition.subtype = kcatransitionfrombottom; transition.timingfunction = [camediatimingfunction functionwithname:kcamediatimingfunctioneaseineaseout]; [self.window.layer addanimation:transition forkey:@"login"]; } ...
logincontroller.php:
... - (ibaction)ontapsignupbutton:(id)sender { registerviewcontroller *controller = [[[registerviewcontroller alloc] init] autorelease]; [self.navigationcontroller pushviewcontroller:controller animated:yes]; nslog(@"%@", self.navigationcontroller); } ...
return nslog on app start:
2013-02-18 02:18:29.986 app[32652:c07] (null)
it may weird. done same kind of mistake. hope helps you..
check whether have initialised uinavigationcontroller in appdelegate. if yes dont know why got this...if not seek next code
registerviewcontroller *controller = [[[registerviewcontroller alloc] init] autorelease]; uinavigationcontroller *nav=[[uinavigationcontroller alloc]initwithrootviewcontroller:controller] [self.navigationcontroller pushviewcontroller:controller animated:yes];
as per edited code
// load login view uiviewcontroller *loginview = [[[loginviewcontroller alloc] init] autorelease]; uinavigationcontroller *nav=[[uinavigationcontroller alloc]initwithrootviewcontroller:loginview] self.window.rootviewcontroller = nav; [self.window makekeyandvisible];
happy coding !!!
objective-c xcode
No comments:
Post a Comment