iphone - Problem with getting a modalViewController to appear -
i've been fighting hours. i've searched around everywhere , can't seem find solution problem. i'm pretty sure i'm lacking key concepts here.
my appdelegate (didfinishlaunching) sets window , invokes rootviewcontroller:
// create our window uiwindow *window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; [window setbackgroundcolor:[uicolor blackcolor]]; // create our rootviewcontroller rootviewcontroller *controller = [[rootviewcontroller alloc] init]; // add our rootviewcontroller's view our window [window addsubview:controller.view]; // controller owned window's view [controller release]; // show world [window makekeyandvisible];
when add controller.view window's subview, understanding rootvc's loadview automatically called.
in rootvc loadview, create tabbarcontroller, each tab having navigationcontroller , it's own viewcontroller. working fine.
in rootvc viewdidload, i'm checking see if first time user running app, , if so, want throw modal welcome screen. part i'm having trouble with.
i'd keep code out of rootvc's viewdidload method, , ideally able accomplish want this:
welcomeviewcontroller *welcome = [[welcomeviewcontroller alloc] init]; [self presentmodalviewcontroller:welcome animated:true]; [welcome release];
obviously isn't working. welcomevc's loadview hasn't been run yet because haven't explicitly set it's view property. i've played around bunch of different solutions (welcome.view - [[uiview....], using welcomevc's init method set self.view) can't seem modal pop up.
how should accomplish i'm looking for? best practices, , what's best solution keep code tight , tidy?
i'm stuck, solution allow me continue developing app!
although problem not simple, solution is. have wait until main view appears. check condition , present modal view in viewdidappear
method, not in viewdidload
method.
Comments
Post a Comment