ios5旋转屏幕:(以下为关健代码,附件中有实例)
竖屏和横屏是两个不同的ViewController,在实现时需建两个viewController
//屏幕旋转
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
//场景跳转方式一
[self performSegueWithIdentifier:@"LandscapeID" sender:self];
//场景跳转方式二(编程方式实现)
// UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
// LandscapeViewController *land = [mainStoryboard instantiateViewControllerWithIdentifier:@"myLandscape"];
// land.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
// [self presentViewController:land animated:YES completion:nil];
return YES;
}else if(toInterfaceOrientation == UIInterfaceOrientationPortrait) {
return YES;
}else {
return NO;
}
}
//相关旋转方法可以测试下
//旋转方向发生改变时
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
}
//视图旋转动画前一半发生之前自动调用
-(void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
}
//视图旋转动画后一半发生之前自动调用
-(void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation duration:(NSTimeInterval)duration {
}
//视图旋转之前自动调用
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
}
//视图旋转完成之后自动调用
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
}
//视图旋转动画前一半发生之后自动调用
-(void)didAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
}
分享到:
相关推荐
ios屏幕旋转
解决iOS5.1与iOS6.0的屏幕旋转兼容的demo
强制转屏
iOS强制屏幕旋转兼容iOS11到iOS17
IOS屏幕旋转完美解决,不使用私有方法 适合场景:App中启动其它游戏或者组件时屏幕方向问题 解决办法:使用多个UIViewController之间的切换实现屏幕旋转
ios6.0的屏幕旋转机制和之前的版本有很大的不同了,这个资源就是我自己写的支持ios6.0屏幕旋转的例子。是navigationController作为rootViewController的例子,通过重写一个navigationController类来实现。对屏幕旋转...
使用uiwindow实现的一个可适应屏幕旋转的ios悬浮窗,简单清晰,一句话可调用实现
两种实现屏幕旋转控制的方法,第一种适合于全局控制,第二种适合于局部控制
当屏幕旋转时重新设置控件的布局,使之适合新的布局
ipad设置支持横竖屏,代码内实现强制竖屏,并且部分controller支持横屏
ios全局竖屏某界面横屏,支持delegate设置,内含tabbar和nav设置
ios demo,UIInterfaceOrientation,屏幕旋转的实例
在屏幕不旋转的情况下,强制旋转系统的UIAlertController!
屏幕旋转,按钮进行设置竖屏还是横屏
ios 页面跳转及屏幕旋转demo(无xib),分享出来,欢迎指正
要让你的APP支持旋转,你需要进行如下几个步骤 1、 全局配置 在工程->TARGETS->General->Deployment Info中配置 在AppDelegate中配置 - (UIInterfaceOrientationMask)application:(UIApplication *)application ...
主要介绍了iOS屏幕旋转与锁屏的示例代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
目前多大数用户的苹果手机基本都有螺旋仪和加速器,我们可以根据这个东西来判断