整个App只有一个页面是横屏(视频)的实现逻辑
2016-01-07 21:19
375 查看
我们在开发视频软件的时候会实现只有视频播放页面实现横屏,其它页面都是竖屏显示
1、首先我们要知道我们的程序入口root所关联的controller;
2、如果是UITabBarController或UINavigationController,那我们就要实现一个继承它们的子类,在里边实现如下三个方法;
3、//当前Viewcontroller是否支持转屏
- (BOOL)shouldAutorotate {
}
//当前viewcontroller支持那些转屏方向
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
}
//当前viewcontroller默认的屏幕方向
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
}
4、实现横竖屏切换的方法(首先要保证你的屏幕是支持横竖屏转换的)
//横屏点击按钮, 旋转到竖屏
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"];//这句话是防止手动先把设备置为竖屏,导致下面的语句失效.
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];
//竖屏点击按钮 旋转到横屏
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];//这句话是防止手动先把设备置为横屏,导致下面的语句失效.
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"];
1、首先我们要知道我们的程序入口root所关联的controller;
2、如果是UITabBarController或UINavigationController,那我们就要实现一个继承它们的子类,在里边实现如下三个方法;
3、//当前Viewcontroller是否支持转屏
- (BOOL)shouldAutorotate {
}
//当前viewcontroller支持那些转屏方向
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
}
//当前viewcontroller默认的屏幕方向
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
}
4、实现横竖屏切换的方法(首先要保证你的屏幕是支持横竖屏转换的)
//横屏点击按钮, 旋转到竖屏
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"];//这句话是防止手动先把设备置为竖屏,导致下面的语句失效.
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];
//竖屏点击按钮 旋转到横屏
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];//这句话是防止手动先把设备置为横屏,导致下面的语句失效.
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"];
相关文章推荐
- android之基于Echart的图表
- 【Android】利用Bundle在不同Activity之间传递数据
- ios项目中安装和使用CocoaPods
- 在Swift中使用遗留的C API
- 关于Qt creator的android配置
- Android中的Loaders机制(5)
- Type mismatch: cannot convert from Object to String
- CSAPP:网桥的自学习算法
- 蓝懿ios技术交流和心得分享16.1.7
- Android中的Loaders机制(4)
- IOS 开发流程
- Android TextView 文字空白解决方案
- Android中的Loaders机制(3)
- android 开发过程中采过的那些坑--工具篇2
- Android 图片识别文字APP
- Android中的Loaders机制(2)
- 联芯平台Android开关机动画制作
- swift场景转换2和委托
- swift中UIkit场景转换
- swift中的uitable