iOS 单页UIWebView播放视频,需要横屏
来源:互联网 发布:淘宝暗语 编辑:程序博客网 时间:2024/05/17 23:37
在项目中遇到了一个小问题,就是在应用本身是竖屏情况下,有某个页面需要支撑横屏时,需要怎么修改。
首先 我需要横屏的 是一个通用UIWebView 播放视频的界面。
第一种方法:
AppDelegate.h 添加 @property(nonatomic, assign) BOOL allowRotation;
AppDelegate.m 添加方法
-(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
if (self.allowRotation) {
returnUIInterfaceOrientationMaskAll;
}
returnUIInterfaceOrientationMaskPortrait;
}
再在 需要横屏的页面
viewDidLoad:
[[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(begainFullScreen)name:UIWindowDidBecomeVisibleNotificationobj ect:nil];//进入全屏
[[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(endFullScreen)name:UIWindowDidBecomeHiddenNotificationobject:nil];
以及方法:
// 进入全屏
-(void)begainFullScreen
{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplicationsharedApplication]delegate];
appDelegate.allowRotation =YES;
}
// 退出全屏
-(void)endFullScreen
{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplicationsharedApplication]delegate];
appDelegate.allowRotation =NO;
//强制归正:
if ([[UIDevicecurrentDevice] respondsToSelector:@selector(setOrientation:)]) {
SEL selector =NSSelectorFromString(@"setOrientation:");
NSInvocation *invocation = [NSInvocationinvocationWithMethodSignature:[UIDeviceinstanceMethodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setTarget:[UIDevicecurrentDevice]];
int val =UIInterfaceOrientationPortrait;
[invocation setArgument:&valatIndex:2];
[invocation invoke];
}
}
- (BOOL)shouldAutorotate
{
return [self.viewControllers.lastObjectshouldAutorotate];
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return [self.viewControllers.lastObjectsupportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [self.viewControllers.lastObjectpreferredInterfaceOrientationForPresentation];
}
// 支持设备自动旋转
- (BOOL)shouldAutorotate
{
returnYES;
}
// 支持横竖屏显示
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
returnUIInterfaceOrientationMaskAll;
}
- iOS 单页UIWebView播放视频,需要横屏
- iOS UIWebView 全屏播放视频, 需横屏,单app不支持横屏, 解决办法
- iOS UIWebView 全屏播放视频, 需横屏,单app不支持横屏, 解决办法
- iOS UIWebView 全屏播放视频, 需横屏,单app不支持横屏, 解决办法
- iOS UIWebView 全屏播放视频, 需横屏,单app不支持横屏, 解决办法
- iOS 土豆视频播放,UIwebview播放视频
- UIWebView视频播放横竖屏
- iOS 全局禁止横屏,但UIWebView 全屏横屏播放视频的解决办法
- iOS UIWebView 全屏播放视频横屏 app其他页面不支持横屏
- iOS 全局禁止横屏,但UIWebView 全屏播放视频,横屏,解决办法
- ios UIWebView 播放优酷土豆视频
- iOS UIWebView播放视频崩溃问题
- ios UIWebView播放视频、音频退出时停止播放
- UIWebView播放视频支持横竖屏问题
- UIWebView 播放视频
- 求教 UIWebview播放视频
- 使用 UIWebView 来播放视频
- UIWebView中视频播放屏幕自动旋转,app不支持旋转但是某一个页面需要旋转等
- YII框架的增删改查
- 属于你的深度学习!
- 标准的Java编码规范手册
- Google Translate —— 不只是翻译
- hadoop之MapReduce输入(split)输出
- iOS 单页UIWebView播放视频,需要横屏
- [HNOI2003]激光炸弹
- Python中的变量和类型
- eclipse 常用功能
- 微信公众号 请求url超时解决方案
- tar压缩隐藏文件
- LeapMotion开发(六)-- 手势识别_猜拳(实时率很高,有动图展示)
- 12 个最佳的免费学习编程的游戏网站
- Linux下DIR,dirent,stat等结构体详解