从其他应用程序启动Youtube应用程序无法在ios 9中运行

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"https://www.youtube.com/watch?v=VideoID"]]) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.youtube.com/watch?v=VideoID"]]; } 

输出:-canOpenURL:url失败:“youtube://www.youtube.com/watch?v = UFccvtrP1d8” – 错误:“此应用不允许查询方案youtube”

尝试这个

在iOS 9中,您必须将您的应用程序想要在LSApplicationQueriesSchemes键(字符串数组)下的Info.plist中查询的任何URL方案列入白名单:

添加字符串作为youtube

例如

 LSApplicationQueriesSchemes  youtube  

二次检查您的设备中是否有可用的YouTube应用程序

例如

  NSString *Name = @"VideoID"; NSURL *linkToApp = [NSURL URLWithString:[NSString stringWithFormat:@"youtube://watch?v=%@",Name]]; // I dont know excatly this one NSURL *linkToWeb = [NSURL URLWithString:[NSString stringWithFormat:@"https://www.youtube.com/watch?v=%@",Name]]; // this is correct if ([[UIApplication sharedApplication] canOpenURL:linkToApp]) { // Can open the youtube app URL so launch the youTube app with this URL [[UIApplication sharedApplication] openURL:linkToApp]; } else{ // Can't open the youtube app URL so launch Safari instead [[UIApplication sharedApplication] openURL:linkToWeb]; } 

有关播放Youtubevideo的更多信息