在iOS上播放YouTube视频的唯一方法是使用默认的YouTube播放器播放它们.您应该将视频嵌入到uiwebview中,当您点击/点击它时,默认播放器将打开,请参阅此代码以在uiwebview中嵌入视频 -
- (void)embedYouTube:(NSString*)url frame:(CGRect)frame { NSString* embedHTML = @"\ \ \ \ \ "; NSString* html = [NSString stringWithFormat:embedHTML, url, frame.size.width, frame.size.height]; if(videoView == nil) { videoView = [[UIWebView alloc] initWithFrame:frame]; [self.view addSubview:videoView]; } [videoView loadHTMLString:html baseURL:nil]; }