Xavi Valero
Xavi Valero

Reputation: 2057

How to push a UIViewController from appDelegate

I have a UIViewController (say A). On the click of a button in the UIViewController(A), I load a UIWebView. On click of a component in the UIWebView, I need to push the UIViewController(A) once again. But I am handling the click event in the webview inside the appdelegate class. How will I push the UIViewController from the appdelegate class.

The click of a component in the UIWebView is handled by

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
}

in the appdelegate

Upvotes: 0

Views: 5699

Answers (1)

Christian Schnorr
Christian Schnorr

Reputation: 10776

As long as you have a reference to your main window and having a NavigationController onscreen, this should do fine: (iOS 4 required)

UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
[navigationController pushViewController:newViewController animated:YES];

Upvotes: 5

Related Questions