Reputation: 47
I have a UIWebView
into which I want to load this URL
https://itunes.apple.com/us/album/blurred-lines-feat.-t.i.-pharrell/id621507456.
This link works on the desktop version of Chrome and Safari, but does not work in the iOS Simulator version of Safari (it says "Safari could not load the page because the address is invalid"). To make sure that this is not a problem due to my setting up my UIWebView
improperly, I tried loading http://www.apple.com
in the web view, and that works fine.
Also, for some odd reason, the link worked one time, then I restarted the application and it did not work. That happened several times.
How can I get the URL to load?
Upvotes: 1
Views: 1007
Reputation: 1505
I guess itunes link will be detected as a app rather than a descent link. So, in iPhone UIWebView will not load the URL. But work around is there. Implement the below UIWebview delegate
method
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)req navigationType:(UIWebViewNavigationType)navigationType {
if([req.URL.absoluteString hasPrefix:@"https://itunes.apple.com"]){
[[UIApplication sharedApplication] openURL:req.URL];
return NO;
}
return YES;
}
Only problem of this approach is that, this will send running app to background and open default iTunes app of iOS.
Upvotes: 0
Reputation: 126
iTunes store can NOT be open in Simulator. Run it on your device.
Simple reason is that Apple don't allow you open it in Simulator.
Imagine if you can open it in Simulator. What happen if you purchase apps?
Upvotes: 1