在我的應用我用以下,這是當UIWebView
已經在屏幕上:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
NSString *urlString = [userInfo objectForKey:@"url"];
if([self.window.rootViewController isKindOfClass:[UINavigationController class]]){
UINavigationController *currentNavigationController = (UINavigationController*)self.window.rootViewController;
if([currentNavigationController.visibleViewController isKindOfClass:[NHCallVC class]]){
SomeViewController *currentViewController = (SomeViewController*)currentNavigationController.visibleViewController;
[currentViewController.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]];
}
}
}
與UINavigationController
結構看似複雜,但是這是需要我設置方式我應用程序。這可以在你的應用程序中有所不同。
這個想法是讓打開的視圖控制器在UIWebView
上加載一個URL。代碼假設UIViewController
與UIWebView
當前處於打開狀態。如果您想在UIWebView
中打開網址之前導航到正確的UIViewController
,則應該更改代碼。
謝謝,我會試試:) –