如果我的网址是youtube.com/watch?v=Hj57OP5C-ls ..我应该在代码中添加什么内容?我应该添加到超链接?
- (IBAction)btnYoutube:(id)sender {
NSURL *linkToAppURL = [NSURL URLWithString:[NSString stringWithFormat:@"youtube://user/%@",@"toyotaleasing"]];
NSURL *linkToWebURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.youtube.com/user/%@",@"toyotaleasing"]];
if ([[UIApplication sharedApplication] canOpenURL:linkToAppURL]) {
// Can open the youtube app URL so launch the youTube app with this URL
[[UIApplication sharedApplication] openURL:linkToAppURL];
}
else{
// Can't open the youtube app URL so launch Safari instead
[[UIApplication sharedApplication] openURL:linkToWebURL];
}
}
刚刚做了,相同,但认为它工作! :) – Samia
伟大:)快乐编码:) –