问题
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.
- In which way can I add this button to my UIView? Do I have to insert a standard button? Which method do I have to call?
- Is it possible to dynamically compose the iTunes url?
I've tried to implement the following method:
- (void) openItunes
{
NSString *iTunesLink = selectedAlbum.itunesLink;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
}
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?
Regards, yassa
回答1:
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
来源:https://stackoverflow.com/questions/8647003/insert-download-on-itunes-button-in-app