插入"从iTunes下载"按钮的应用程序

问题描述:

我的应用程序显示某首歌曲的标题,我想插​​入iTunes下载按钮,打开iTunes的在我的iPhone指向我的歌。
我检索了正确的iTunes网址,使用的 iTunes的链接设备
但我有两个问题给你。

My app shows the title of a certain song and I would like to insert a "Download on iTunes" button that open iTunes on my iPhone pointing to my song. I've retrieved the correct iTunes url, using the iTunes Link Maker but I've two questions for you.


  • 在哪种方式我可以将此按钮添加到我的UIView?我一定要插入一个标准的按钮?我有哪些方法来调用?

  • 是否有可能动态组成iTunes网址?

我试图实现以下方法:

- (void) openItunes
{
    NSString *iTunesLink = selectedAlbum.itunesLink;
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
}

iTunesLink ITMS://itunes.apple.com/it/album / ... 。如果我推出这个网址的Safari,iTunes会自动打开专注于正确的歌曲。但是,如果我调用 openItunes 方法从模拟器或iPad的触摸没有反应。
任何想法?

with iTunesLink like itms://itunes.apple.com/it/album/.... If I launch this url with Safari, iTunes is automatically opened focusing on the right song. But if I invoke the openItunes method from simulator or iPad Touch nothing happens. Any ideas?

问候,yassa

最后这个工作对我来说:

Finally this worked for me:

- (IBAction)buyAlbum:(id)sender
{
    NSString* url = @"itms://itunes.apple.com/it/album/love-life-lamore-e-la-vita/id298792107?uo=4";

    [[UIApplication sharedApplication] openURL: [NSURL URLWithString: url ]];
}

yassa