我有来自AppStore的链接制作者的应用程序链接。我的应用中有UIWebView
,我正在尝试加载UIWebView
中的链接,但每次加载该链接时,都会打开内置的AppStore,而不是在UIWebView
中显示内容。我想打开UIWebView
中的链接,而不是打开内置的iOS AppStore。
这是我试过的
- (void)viewDidLoad
{
str = @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa";
str = [NSString stringWithFormat:@"%@/wa/viewContentsUserReviews?", str];
str = [NSString stringWithFormat:@"%@type=Purple+Software&id=", str];
// Here is the app id from itunesconnect
str = [NSString stringWithFormat:@"%@289382458", str];
[webOpenApp loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
}
-(BOOL) webView:(UIWebView *)inWeb
shouldStartLoadWithRequest:(NSURLRequest *)inRequest
navigationType:(UIWebViewNavigationType)inType
{
if (inType == UIWebViewNavigationTypeOther) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
return NO;
}
return YES;
}
答案 0 :(得分:1)
itms-apps://
是一种特殊协议,当iOS系统读取此内容时,它将启动App Store以显示该应用。显然这不是你想要的。
您应该自己构建UI以显示应用程序的信息。当用户单击“购买”按钮时,您必须将用户重定向到App Store。因为App Store是用户可以购买和下载应用程序的唯一地方。