我想根据从 URL 方案获得的 id 打开特定的 UIViewController。
例如 myapp://news/285 将打开显示此特定新闻的 UIViewController“新闻”。
我在这里收到通知:
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)source
annotation:(id)annotation
{
if ([[url scheme] isEqualToString:@"myapp"]) {
NSString *urlString = url.absoluteString;
...
return YES;
}
return NO;
}
但是我应该如何推送 UIViewController ?我无法从这里访问导航 Controller 。
(我正在考虑使用 NSNotficationCenter 向我的主页发送带有 id 的通知,然后从那里推送 UIViewController。你觉得怎么样?)
谢谢
最佳答案
您知道您查看设置。因此,当您的 rootViewController 是 UINavigationController 时,您可以使用:
UINavigationController *navCon = (UINavigationController*)self.window.rootViewController;
[navCon pushViewController:myPushedVC animated:NO];
如果没有,那么也许使用通知方法会更容易
关于ios - 推送通知后从 URL 方案打开 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20548591/