简体   繁体   中英

Communication between a UIWebView and UINavigationController?

I have a app where users can connect with numerous websites. I have a UINavigationController that displays all the websites. It will push when the user taps on into a webView in a different view controller.

This all is fine, but when the user is done, how can the UIViewController communicate with the app and tell it to pop back one? I have compete control of the php files in the webView, so it should be easy, right?

I was thinking about getting the title from the javascript file every time it loads. If it's a special, then go back? What would be the best way in doing this?

I haven't been able to find anything on the internet. If you could just point me in the right direction, that would be fantastic!

Thanks, Coulton

I'm unsure what you mean by "when the user is done" - do you mean when the user has finished viewing the selected webpage and wants to go back to the list?

If so, you already will have pushed your UIViewController on to the UINavigationController which is not much more than a stack of UIViewController instances. Every UIViewController has a navigationController property which is nil until the view controller is pushed onto a navigation controller.

With that in mind, try calling:

[self.navigationController popViewControllerAnimated:yesOrNo]

where self should be the view controller you want to pop.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM