ios - Pushing a view when the rootViewController is not a UINavigationController -
alright, i've been looking around answer following question: how push view controller view when push notification arrives appdelegate?
and answers if rootviewcontroller uinavigationcontroller, have instantiate view via storyboard , push root navigation controller.
here's situation. here's how storyboard organised:

so see rootviewcontroller doesn't have uinavigationcontroller. so, how go pushing view out of storyboard?
note: presenting separate modal view push notifications isn't great idea. it's last resort.
i'd solution in apple mail , message apps.
alright, guess don't give :) here's solution found problem. since presenting main app views within modal view controller, here's did:
since ios 5 every view controller has presentedviewcontroller property. once know that, it's pretty easy there. here's specific code inside appdelegate.m
- (void) application:(uiapplication *)application didreceiveremotenotification:(nsdictionary *)userinfo { if ([[userinfo objectforkey:@"notificationtype"] isequaltostring: @"messagetype"]) { uitabbarcontroller * tabbarcontroller = (uitabbarcontroller *)[self.window.rootviewcontroller presentedviewcontroller]; [tabbarcontroller setselectedindex:kchatviewindex]; // view controller presented modally tabbar, case can different. // ... here can reach navigation controller or other view inside app } now since you've got view controller, can use setselectedindex: if it's tabbarcontroller, or push view controller if it's navigation unit.
hope helps similar problem. cheers!
Comments
Post a Comment