0
我需要從應用程序的委託選項卡上選擇索引並調用視圖控制器的功能,該選項卡中的故事板如何在appdelegate的選項卡視圖中調用控制器。故事板
(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSString *alertMessage = [[userInfo objectForKey:@"aps"] valueForKey:@"alert"];
if (alertMessage != nil){
UITabBarController *tabb = (UITabBarController *)self.window.rootViewController;
tabb.selectedIndex = 2;
// Need to call a method in my SpecialsViewController which manages properties and functions of tab with index 2
}
}
UITabBarController * tabb =(UITabBarController *)self.window.rootViewController; tabb.delegate = self; UIViewController * controller = [tabb.viewControllers objectAtIndex:2]; if(controller!= nil){controller LoadSpecialsWebsite]; } –
繼承人我的代碼AppDelegate.m但我得到這個錯誤: - [UINavigationController的LoadSpecialsWebsite]:無法識別的選擇發送到實例 的UITabBarController *塔布=(*的UITabBarController)self.window.rootViewController; 的UIViewController *控制器= [tabb.viewControllers objectAtIndex:2]; if(controller!= nil){controller LoadSpecialsWebsite]; } //SpecialsViewController.m - (無效)LoadSpecialsWebsite { 的NSLog(@ 「LoadSpecialsWebsite」); } –
確定執行以下操作 的UITabBarController *塔布=(的UITabBarController *)self.window.rootViewController; UINavigationController * controller = [tabb.viewControllers objectAtIndex:2]; if(controller!= nil){[controller.viewControllers.lastObject LoadSpecialsWebsite]; } // // SpecicalViewController.m - (void)LoadSpecialsWebsite {NSLog(@「LoadSpecialsWebsite」); } –