iOS中强制转换
2015-12-23 17:20
507 查看
iOS中强制转换
// 视图显示为横屏状态,温柔转换
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation ==
UIInterfaceOrientationLandscapeLeft);
}
-(BOOL)shouldAutorotate {
return
YES;
}
-(UIInterfaceOrientationMask)supportedInterfaceOrientations {
return
UIInterfaceOrientationMaskLandscapeLeft;
}
// 强制旋转
- (IBAction)tranfromOnClick:(UIButton *)sender
{
if ([UIDevice
currentDevice].orientation ==
UIDeviceOrientationPortrait)
{
[[UIDevice
currentDevice] setValue:[NSNumber
numberWithInteger:UIDeviceOrientationPortrait]
forKey:@"orientation"];//这句话是防止手动先把设备置为横屏,导致下面的语句失效.
[[UIDevice
currentDevice] setValue:[NSNumber
numberWithInteger:UIDeviceOrientationLandscapeLeft]
forKey:@"orientation"];
} else {
[[UIDevice
currentDevice] setValue:[NSNumber
numberWithInteger:UIDeviceOrientationLandscapeLeft]
forKey:@"orientation"];//这句话是防止手动先把设备置为竖屏,导致下面的语句失效.
[[UIDevice
currentDevice] setValue:[NSNumber
numberWithInteger:UIDeviceOrientationPortrait]
forKey:@"orientation"];
}
}
// 视图显示为横屏状态,温柔转换
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation ==
UIInterfaceOrientationLandscapeLeft);
}
-(BOOL)shouldAutorotate {
return
YES;
}
-(UIInterfaceOrientationMask)supportedInterfaceOrientations {
return
UIInterfaceOrientationMaskLandscapeLeft;
}
// 强制旋转
- (IBAction)tranfromOnClick:(UIButton *)sender
{
if ([UIDevice
currentDevice].orientation ==
UIDeviceOrientationPortrait)
{
[[UIDevice
currentDevice] setValue:[NSNumber
numberWithInteger:UIDeviceOrientationPortrait]
forKey:@"orientation"];//这句话是防止手动先把设备置为横屏,导致下面的语句失效.
[[UIDevice
currentDevice] setValue:[NSNumber
numberWithInteger:UIDeviceOrientationLandscapeLeft]
forKey:@"orientation"];
} else {
[[UIDevice
currentDevice] setValue:[NSNumber
numberWithInteger:UIDeviceOrientationLandscapeLeft]
forKey:@"orientation"];//这句话是防止手动先把设备置为竖屏,导致下面的语句失效.
[[UIDevice
currentDevice] setValue:[NSNumber
numberWithInteger:UIDeviceOrientationPortrait]
forKey:@"orientation"];
}
}
相关文章推荐
- iOS中消息的传递机制
- iOS使用NSMutableAttributedString 实现富文本(不同颜色字体、划线等等)
- iOS如何隐藏NavigationBar
- IOS开发微博中涉及到的一些正则表达式(表情,话题,链接,@)
- iOS 深浅拷贝
- iOS开发简单的实现后台任务(诸如后台播放音乐,定时器等)
- iOS在Xcode中,文件名后小方框中的A(M或C)代表的意思
- iOS AES加密解密实现方法
- iOS如何使屏幕一直保持亮屏?
- IOS手势操作
- iOS开发-CoreMotion框架(加速计和陀螺仪)
- iOS AES128 CBC No Padding加密解密
- iOS 开发项目之 QQ 音乐
- IOS block简单使用
- 开源中国iOS客户端学习——(十一)AES加密
- iOS 根据文字内容动态设置宽度与高度
- iOS strong,retain,assign,weak,copy属性实测
- iOS SHA1加密实现方法
- 关于ios 集成支付宝功能的大概
- iOS开发CADisplayLink和NSTimer