iOS 推送通知重定向 - 故事板
iOS pushNotice redirect - stroyboard
我想在应用程序外触摸推送通知警报时重定向到特定视图。我写了一些这样的代码...
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler
{
if (application.applicationState != UIApplicationStateActive){
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ChatViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"ChatView"];
[self.window.rootViewController presentViewController:vc animated:YES completion:nil];
}
}
确实重定向到 chatViewController,但只启动了 chatViewController。我是否必须写下我的应用程序的整个 Controller
结构,还是有其他方法可以这样做?
我的应用程序的结构是一个带有四个选项卡的 UITabBarViewController...
tab1 > UINavigationController > UICollectionViewController > UIViewController
tab2 > UINavigationController > UICollectionViewController
tab3 > UINavigationController > UITableView > UITableView(chatViewController)
tab4 > UITableView
我相信您应该创建视图控制器堆栈。
首先你说要推送到第一个 table 视图控制器,并提到推送即将到来。您可以调用推送构造函数。下面是 UITableViewController* 中的代码。
tab3 > UINavigationController > UITableViewController。
- (id)initWithPush:(Chart*)chart {
self = [self initWithNibName:<#(NSString *)#> bundle:<#(NSBundle *)#>];
if (self) {
[self pushToChart:chart];
}
return self;
}
- (void)pushToChart:(Chart*)chart {
// add the code to push to next Chart-View-Controller
}
我找到了如何在故事板中获取 viewController。所以我可以直接这样做...
UITabBarController *tab = (UITabBarController *)self.window.rootViewController;
UINavigationController *nav = tab.viewControllers[0];
tab.selectedViewController = nav;
myViewController *vc = (ChatListViewController *)nav.topViewController;
[vc.navigationController pushViewController:vc animated:YES];
我想在应用程序外触摸推送通知警报时重定向到特定视图。我写了一些这样的代码...
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler
{
if (application.applicationState != UIApplicationStateActive){
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ChatViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"ChatView"];
[self.window.rootViewController presentViewController:vc animated:YES completion:nil];
}
}
确实重定向到 chatViewController,但只启动了 chatViewController。我是否必须写下我的应用程序的整个 Controller
结构,还是有其他方法可以这样做?
我的应用程序的结构是一个带有四个选项卡的 UITabBarViewController...
tab1 > UINavigationController > UICollectionViewController > UIViewController
tab2 > UINavigationController > UICollectionViewController
tab3 > UINavigationController > UITableView > UITableView(chatViewController)
tab4 > UITableView
我相信您应该创建视图控制器堆栈。
首先你说要推送到第一个 table 视图控制器,并提到推送即将到来。您可以调用推送构造函数。下面是 UITableViewController* 中的代码。
tab3 > UINavigationController > UITableViewController。
- (id)initWithPush:(Chart*)chart {
self = [self initWithNibName:<#(NSString *)#> bundle:<#(NSBundle *)#>];
if (self) {
[self pushToChart:chart];
}
return self;
}
- (void)pushToChart:(Chart*)chart {
// add the code to push to next Chart-View-Controller
}
我找到了如何在故事板中获取 viewController。所以我可以直接这样做...
UITabBarController *tab = (UITabBarController *)self.window.rootViewController;
UINavigationController *nav = tab.viewControllers[0];
tab.selectedViewController = nav;
myViewController *vc = (ChatListViewController *)nav.topViewController;
[vc.navigationController pushViewController:vc animated:YES];