我在iOS 5上成功收到我的通知。我想要在用戶滑動或點按通知中心內的推送通知時能夠將用戶發送到特定視圖。從推送通知中推送視圖
視圖控制器(視圖)我希望用戶去反對剛開始我的應用程序是「groceryStoreViewController」。我已經讀過,這是在didFinishLaunchingWithOptions或didReceiveRemoteNotification中完成的,但我不確定。
如果有人知道如何做到這一點,我真的很感激它,因爲它確實是一場鬥爭。
感謝
編輯
所以,問題是,我想,當用戶點擊一個通知要打開特定視圖控制器,但我也希望UITabBar保持。我還沒有成功地做到這一點,這與我相信顯示子視圖有關。請讓我知道你的想法,並非常感謝你。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.tabBarItem = [[[UITabBarItem alloc] init] autorelease];
exploreViewController *view1 = [[exploreViewController alloc] initWithNibName:@"exploreViewController" bundle:nil];
view1.title= @"Explore";
Upcoming *view2 = [[Upcoming alloc] initWithNibName:@"Upcoming" bundle:nil];
view2.title = @"Upcoming";
TipsViewController *view3 = [[TipsViewController alloc] initWithNibName:@"TipsView" bundle:nil];
view3.title = @"Tips";
UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:view1];
UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:view2];
UINavigationController *nav3 = [[UINavigationController alloc] initWithRootViewController:view3];
[view1 release];
[view2 release];
[view3 release];
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:nav1,nav2,nav3,nil];
self.tabBarItem = [[[UITabBarItem alloc] init] autorelease];
[nav1 release];
[nav2 release];
[nav3 release];
if (launchOptions != nil)
{
NSDictionary *remoteNotif = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
NSLog(@"Launched from push notification");
//Accept push notification when app is not open
if (remoteNotif) {
NSDictionary *alertBody = [remoteNotif objectForKey:@"loc-key"];
self.window.rootViewController = nav2; //this is what I want displayed when tapped but also maintain tab bar controller
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
}
}
else {
//Go here if just loading up normally without push
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
}
return YES;
}
問題沒有得到很好的定義! – 2012-04-27 06:31:06
@hp iOS編碼器:並不是每個用戶在這裏都能很好地說英語。所以請善待,並給它一個鏡頭.. – filou 2012-05-14 11:51:44