设置屏幕旋转 (以下方法按着顺序设置)

UIInterfaceOrientationUnknown            = UIDeviceOrientationUnknown, 界面取向未知

UIInterfaceOrientationPortrait           = UIDeviceOrientationPortrait, 正常的肖像模式 就是向上

UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown, 向下

UIInterfaceOrientationLandscapeLeft      = UIDeviceOrientationLandscapeRight,  向右

UIInterfaceOrientationLandscapeRight     = UIDeviceOrientationLandscapeLeft   向左

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

返回YES支持旋转 NO不支持旋转

通过获取UIDevice的userInterfaceIdiom属性,可以检测到当前程序是运行在iphone或者是ipad上

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {

return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);

} else {

return YES;

}

}

这个方法是发生在翻转开始之前。一般用来禁用某些控件或者停止某些正在进行的活动,比如停止视频播放

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

这个方法发生在翻转的过程中,一般用来定制翻转后各个控件的位置、大小等。可以用另外两个方法来代替:willAnimateFirstHalfOfRotationToInterfaceOrientation:duration:   和  willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

这个方法发生在整个翻转完成之后。一般用来重新启用某些控件或者继续翻转之前被暂停的活动,比如继续视频播放。

时间: 2024-08-08 01:16:38

设置屏幕旋转 (以下方法按着顺序设置)的相关文章

当rootViewController为tabbarController时,控制屏幕旋转的方法

在ios6以后,ios系统改变了屏幕旋转的方法,如果要设置屏幕旋转的方法,需要在rootvc里面进行编写,例如 UIViewController *viewCtrl = [[UIViewController alloc] init]; UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:viewCtrl]; if ([window respondsToSelect

ios实现屏幕旋转的方法

1.屏蔽AppDelegate下面的屏幕旋转方法 #pragma mark - 屏幕旋转的 //- (UIInterfaceOrientationMask)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window //{ // return UIInterfaceOrientationMaskPortrait; //} 2.对UINavigationContr

Android应用不随手机屏幕旋转的方法

在主配置文件里面.在需要设置的activity项后面加上 android:screenOrientation="portrait",这个activity就保持竖屏显示了:在每个activity项后面加上android:screenOrientation="portrait",整个应用就保持竖屏显示.

cocos2d怎么设置屏幕朝向?横屏 or 竖屏设置

在cocos引擎里面找了好久.没找到相关接口,网上也搜索了好久,最后发现.原来须要依据各个平台分别进行设置. android 改动项目根文件夹 proj.android\AndroidManifest.xml 文件里的android:screenOrientation属性值,portrait 为竖屏,landscape为横屏 Windows 直接用cocos引擎接口中的GLView::createWithRect方法指定窗体大小,须要注意的是.该方法在android环境下会报错,并导致程序崩溃,

关于IOS屏幕旋转的几个问题1.常规设置2.个别页面强制固定横竖屏

1.常规设置屏幕旋转  (Device Orientation || info.plist-----这两个地方的设置是同步的) 1)targets->General->Deployment Info->Device Orientation  直接勾选想要的设备定位全局属性 2)Supporting Files->Info.plist->Supported interface orientations 增删属性值 2.个别页面强制横竖屏 新建一个NavigationContro

关于屏幕旋转的几种情况

一.设备旋转(上苹果商店有风险) *这种方法当在General中勾选了Device Orieation 的Protrait后再用下面代码不能设置屏幕旋转至横屏. if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { [[UIDevice currentDevice] performSelector:@selector(setOrientation:) withObject:(id)UIInt

iOS屏幕旋转总结

一.屏幕旋转检测方法 在特别的场景下,需要针对屏幕旋转作特殊处理.在ios系统下实现相关的功能还是比较方便的. 我下面介绍两种方法: 1.监测状态栏方向 1 /** 2 * 当手机屏幕发生左右横屏变化时,我们需根据此时的设备方向做出相应的调整 3 * 例如,在ViewController中,我们需要监控手机屏幕是否转动了,需要在通知中心中注册通知 4 */ 5 - (void)viewWillAppear:(BOOL)animated{ 6 [super viewWillAppear:anima

height与min-height的百分比问题和铺满屏幕的布局方法

1.height的百分比 当我们给块元素设置百分比高度时,往往没能看到效果.因为百分比的大小是相对其最近的父级元素的高的大小,也就是说,其最近的父级元素应该有一个明确的高度值才能使其百分比高度生效. <div id="container1"> <div id="wrap"> wrap's height work </div> </div> <br> <div id="container2&q

ios(ipad,iphone)屏幕旋转检测通用方法

在特别的场景下,需要针对屏幕旋转作特殊处理.在ios系统下实现相关的功能还是比较方便的. 我下面介绍两种方法: 1.注册UIApplicationDidChangeStatusBarOrientationNotification通知(举例:在一个viewcontroller类的viewdidload中注册该通知),示例代码如下: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarO