如何在iPhone应用程序中打开itunes链接?

时间:2011-06-22 05:39:42

标签: iphone objective-c ios4 itunes

我正试图在UIControlEventTouchDown按钮按下事件上打开itunes链接。我的代码如下。

    NSString *urlString =@"http://itunes.apple.com/in/album/carnatic-vocal-sanjay-subrahmanyan/id106924807?ign-mpt=uo%3D4";


    NSString *str_ur=[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    NSURL *url=[NSURL URLWithString:str_ur];

    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [webview_buy loadRequest:requestObj];

    webview_buy.delegate=self;

    [self.view addSubview:webview_buy];

这将转到设备中的itunes并打开itunes商店。但我收到一条警告信息

您的申请无法完成。

请用代码说明。

3 个答案:

答案 0 :(得分:13)

首先从iTunes中复制您要在应用中打开的网址。

然后使用以下代码:

[[UIApplication sharedApplication] 
     openURL:[NSURL URLWithString:@"http://itunes.apple.com/in/album/carnatic-vocal-sanjay-subrahmanyan/id106924807?ign-mpt=uo%3D4"]];

此处,URLWithString值将是您要打开的应用网址。

如有任何困难,请告诉我。

答案 1 :(得分:11)

使用itms-apps://前缀在iTunes中打开,例如

[[UIApplication sharedApplication] 
     openURL:[NSURL URLWithString:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=409954448"]];         

答案 2 :(得分:10)

它仅适用于设备。投诉请求无法在模拟器上完成。

相关问题