简体   繁体   English

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

[英]how to open itunes link in iphone app?

I am trying to open itunes link on UIControlEventTouchDown button press event. 我试图在UIControlEventTouchDown按钮按下事件上打开itunes链接。 My code is as follows. 我的代码如下。

    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];

This will go to itunes in the device and open the itunes store. 这将转到设备中的itunes并打开itunes商店。 But i get an alert message that says 但我收到一条警告信息

Your Request could not be Completed. 您的请求无法完成。

Please give idea with code. 请用代码提出想法。

First copy the url from iTunes which you want to open in app. 首先从iTunes中复制您要在应用中打开的网址。

Then use below code: 然后使用下面的代码:

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

here, URLWithString value will be your app url which you want to open. 在这里,URLWithString值将是您要打开的应用程序URL。

Let me know in case of any difficulty. 如有任何困难,请告诉我。

Use the itms-apps:// prefix to open in iTunes, eg 使用itms-apps://前缀在iTunes中打开,例如

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

It will work only with device. 它只适用于设备。 Throws Request could not be completed on simulator. 投掷请求无法在模拟器上完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM