开发者

How to open any link from a UIWebView to a new UIWebView?

开发者 https://www.devze.com 2022-12-22 21:19 出处:网络
I want to make a simple app, where a UIWebView with custom content will have several links to other pages with similar content as well (and a navigation bar on top, with just a back button).

I want to make a simple app, where a UIWebView with custom content will have several links to other pages with similar content as well (and a navigation bar on top, with just a back button). I read the answers to this question, however I'm not sure if I should do that in my applicati开发者_Go百科on, as the user might be able to go deep enough, and I will be creating new webviews all the time. What could be the best practice for such a behavior?

Thank you!


I'd recommend listening for:

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

and always returning YES (so the webView will continue with the requested link) while storing each request in an NSMutableArray to create a stack of the user's browsing history.

That would let you update a back button's text with the previous page's title (shortened of course).

If you just need to have a back button without label, you could have a simple button hooked up to the UIWebView's - (void) goBack; method.

0

精彩评论

暂无评论...
验证码 换一张
取 消