ios - 从 UIwebview 打开并安装 iOS 应用程序

标签 ios objective-c uiwebview app-store

我有一个应用程序链接,使用来自 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;
}

最佳答案

itms-apps:// 是一个特殊的协议(protocol),当 iOS 系统读取它时,它会启动 App Store 以显示该应用程序。显然这不是您想要的。

您应该自己构建 UI 来显示应用程序的信息。当用户单击购买按钮时,您必须将用户重定向到 App Store。因为 App Store 是用户购买和下载应用程序的唯一场所。

关于ios - 从 UIwebview 打开并安装 iOS 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23731534/

相关文章:

ios - 如何使用 iOS 状态恢复来恢复 UIPopoverController?

javascript - 使用phonegap在webview中加载资源

objective-c - 使用 AFNetworking 在 Objective C 上创建 Api 调用的最佳方法

ios - 调整 UILabel 内的文本

swift - 用图像计算 UIWebView 高度给出了错误的答案

uiwebview - 检测是否在iOS7下启用了一般网站限制

ios - 当此字符串包含中文时,NSDataDetector 无法分析 NSString 中的 url

c++ - 为 iOS 编译 XZ Utils

ios - 从 Apple Watch (Watch OS 2.0) 请求后台任务在父设备上运行

ios - 如何使用 iTunes 文件共享以编程方式将文件传输到 iOS 设备?