编辑:视频是正在使用的应用程序:即它们是设计用于纵向模式播放的教学视频。
我使用这种方法 (NB iPhoneDevSDK.com 目前被 Google 标记为包含恶意软件,所以要小心。我已经上传了相关帖子的屏幕截图)来打开和播放 YouTube 视频(在幕后使用 UIWebView)。
我要展示的视频是纵向录制的(以 320x480 上传),旨在在纵向模式下很好地填满 iPhone 屏幕。但是,YouTube 视频以强制横向模式开始,并且只能通过将手机移动到横向位置然后再返回来将其变为纵向(有时需要执行几次)。
我想知道的是:有没有办法强制 UIWebView 打开默认为纵向模式的视频播放器?
注意我在生成 UIWebView 的 UIWebView 委托上设置了 (interfaceOrientation == UIInterfaceOrientationPortrait)。
编辑:我什至尝试将 UIWebView 子类化,以防止它工作:
@interface AltWebView : UIWebView
@end
@implementation AltWebView
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
- 第一张图片:默认横向播放视频
- 第二张图片:人像模式旋转几次