Ios 在UIWebView中以横向方向播放YouTube视频,而ViewController以纵向方向播放
我正在开发一个需要播放YouTube视频的iPhone应用程序Ios 在UIWebView中以横向方向播放YouTube视频,而ViewController以纵向方向播放,ios,xcode,youtube,uiwebview,landscape,Ios,Xcode,Youtube,Uiwebview,Landscape,我正在开发一个需要播放YouTube视频的iPhone应用程序 -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); } 我有
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
我有一个纵向的ViewController,只有一个加载YouTube视频的UIWebView
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
我想做的是,视频可以横向播放
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
这听起来很简单,但我不知道怎么做。有人能帮我吗
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
谢谢 目前没有办法开始以编程方式播放YouTube视频。
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
也就是说,您可以在ViewController的willRotateToInterfaceOrientation:duration:检查水平方向并使用显示视频缩略图的代码显示网络视图。但用户仍需激活视图。
要删除视频,您可以使用相同的方法,但要选择纵向并删除网络视图。我找到了答案
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
1) 我将此代码添加到我的viewController.m
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
2) 在interface builder中,我在横向中构建界面,每个元素旋转90°
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
当我构建并运行时,视图似乎处于纵向模式,而实际上是横向模式。因此,嵌入UIWebView中的YouTube视频在横向播放。这将在AppDelegate中播放。将仅为视频播放器启用水平模式
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
if let presentedViewController = window?.rootViewController?.presentedViewController {
let className = String(describing: type(of: presentedViewController))
if ["MPInlineVideoFullscreenViewController", "MPMoviePlayerViewController", "AVFullScreenViewController"].contains(className)
{
return UIInterfaceOrientationMask.allButUpsideDown
}
}
return UIInterfaceOrientationMask.portrait
}