IOS 自动(手动)转屏
来源:互联网 发布:13家合法网络筹款平台 编辑:程序博客网 时间:2024/06/03 01:22
一、第一次做转屏的时候走了不少弯路,过一段时间不写,发现忘了差不多了,还好有度娘和google,让我很快找到感觉,下面来谈谈我对转屏的了解(有不对的地方或更好的方法请留言,不胜感激!!!)
iOS6前的转屏比较简单就一个方法
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return (toInterfaceOrientation == UIInterfaceOrientationPortrait) || (toInterfaceOrientation ==UIInterfaceOrientationLandscapeLeft) || (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
iOS6及以后
①告知Appdelegate要支持转屏的方向
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow*)window {
returnself.orientation;
}
②在需转屏的viewController
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
AppDelegate *del = (AppDelegate *)[UIApplicationsharedApplication].delegate;
del.orientation = UIInterfaceOrientationMaskAllButUpsideDown;
}
③在需转屏的viewController加
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
- (BOOL)shouldAutorotate {
returnYES;
}
二、手动转屏(按一个按钮或者一个事件触发)
1、假转屏
①转状态栏
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:YES];
②旋转当前view
self.view.transform = CGAffineTransformRotate(self.view.transform, M_PI/4);
2、用私有方法转屏(此类要在ARC),上Appstore慎用
- (void)setCustomOrientation:(NSString *)orientate {
UIInterfaceOrientation orientation = orientate.intValue;
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
[[UIDevice currentDevice] performSelector:@selector(setOrientation:) withObject:(id)orientation];
}
}
- IOS 自动(手动)转屏
- iOS 自动,手动 屏幕翻转
- iOS 自动释放手动释放混编
- iOS 自动释放手动释放混编
- iOS 自动释放手动释放混编
- iOS手动旋转屏幕、自动旋转屏幕
- iOS 屏幕旋转 手动和自动
- iOS手动和自动旋转屏幕
- 手动 自动
- IOS 多语言本地化 完美解决方案【自动+手动】
- ios:UITableView告别手动上拉更新,自动刷新数据
- iOS 多语言本地化 完美解决方案【自动+手动】
- iOS ---网络请求封装(自动缓存与手动缓存)
- iOS UIViewController 无法关闭自动旋屏(自动旋转、手动旋转、兼容IOS6之前系统)
- 手动/自动选网
- ios学习之 IOS6屏幕旋转详解(自动旋转、手动旋转、兼容IOS6之前系统)
- IOS屏幕旋转详解(自动旋转、手动旋转、兼容IOS6之前系统)
- IOS系列——手动释放和自动释放转换 ARC——MRC
- 31 5个数求最值
- Starting Jetty in Debug Mode With Gradle
- Android应用中平滑的手写效果实现
- 二叉索引树(树状数组)
- 判断ADB调试模式是否打开源代码
- IOS 自动(手动)转屏
- vb.net & 文本框为空提示,一键清空文本框所有内容
- Qt QMap与std map的遍历
- 自己写的图片格式转换工具
- 【Leetcode】Substring with Concatenation of All Words
- zoj 3329 One Person Game(概率dp,期望)
- LeetCode :: Candy
- 下一步计划及问题
- 常量指针与指针常量的区别