2013-11-24 18 views
1

當用戶單擊通知時,我希望應用打開到我的選項卡欄控制器上的第三個選項卡。我可以獲得通知,但不是開放權利部分。在我的應用程序的didFinishLaunchingWithOptions我:打開本地通知到特定視圖

UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; 
    if (localNotif) { 
     tabBarController.selectedIndex = 3; 
    } 

然後在AppDelegate中爲好,我有:

- (void)application:(UIApplication *)application 
didReceiveLocalNotification:(UILocalNotification *)notification { 

    application.applicationIconBadgeNumber = 0; 
    NSString *reminderText = [notification.userInfo 
           objectForKey:kRemindMeNotificationDataKey]; 
    [viewController showReminder:reminderText]; 
    tabBarController.selectedIndex = 3; 
} 

但是,單擊該通知只是打開它,像正常的,到第一個標籤。

回答

0

Here's an example。由於計數從0開始,因此第三個選項卡將爲tabBarController.selectedIndex = 2

相關問題