UIWebView links opening in Safari

。_饼干妹妹 提交于 2019-12-05 08:19:49

You may want to try logging the load requests when you run the app. It may be that apple is automatically changing http:// to itms-apps or http://phobos or something along these lines. If so, then you can block the load when it's call using something like this:

- (BOOL)webView:(UIWebView *)webView 
shouldStartLoadWithRequest:(NSURLRequest *)request 
 navigationType:(UIWebViewNavigationType)navigationType;
{   
    NSURL *loadURL = [[request URL] retain];
    NSLog(@"%@",loadURL);
    if([[loadURL absoluteString] hasPrefix:@"http://"])
    {
        [loadURL release]; 
        return TRUE;
    }
    [loadURL release];
    return FALSE;
}

Good luck. I'm curious to know what finally works.

visakh7

A note from the Apple reference documents- Q: How do I launch the App Store from my iPhone application? Also, how do I link to my application on the store?

Note: If you have iTunes links inside a UIWebView, you can use this technique after intercepting the links with the -[UIWebViewDelegate webView:shouldStartLoadWithRequest:navigationType:] delegate method.

Not sure if you ever got it working, but this works well for me:

NSString *responseString = [NSString stringWithContentsOfURL:myURL];
[self.webView loadHTMLString:responseString baseURL: nil)];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!