简体   繁体   中英

Open link in a new UIWebView?

I have made an app with a Tabbar and an RSS reader in one window. I know how to open the RSS links in the build in safari browser, but how do I open the links in a UIWebView in the same tab instead? I don't want to quit my app to view the webpage, and how do I go back to the RSS view? Simply by hiding the webview?

Use the UIWebViewDelegate method:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType

In that, intercept the link, and load however you like.

I think what you need is Navigation setup.

You should have a Navigation Controller that has your RSS reader as it's root view controller. Then whenever a user selects a story in your RSS feed, create an instance of a new view controller that has a WebView as it's view. You can then pass the URL to the new web view and 'push' the webview onto your navigation stack.

All you have to do then is tell the webview to load the URL you passed it, and it'll do its thing.

Then when the user is done, all they have to do is hit the back button that gets created for you by the Navigation controller.

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