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

Sen*_*mar 5 iphone itunes objective-c ios4

我试图在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];
Run Code Online (Sandbox Code Playgroud)

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

您的请求无法完成.

请用代码提出想法.

Nis*_*t B 13

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

然后使用下面的代码:

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

在这里,URLWithString值将是您要打开的应用程序URL.

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


Pen*_*One 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"]];         
Run Code Online (Sandbox Code Playgroud)


pal*_*aja 10

它只适用于设备.投掷请求无法在模拟器上完成.