资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

ios屏幕旋转

手机屏幕旋转时,试图控制器可以相应一些方法,可以再这些方法里自己布局视图

成都创新互联公司网站建设提供从项目策划、软件开发,软件安全维护、网站优化(SEO)、网站分析、效果评估等整套的建站服务,主营业务为成都网站建设、成都网站设计,重庆APP软件开发以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。成都创新互联公司深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!

旋转方向的枚举类型

typedefNS_ENUM(NSInteger, UIInterfaceOrientation) {

   UIInterfaceOrientationPortrait           =UIDeviceOrientationPortrait,

   UIInterfaceOrientationPortraitUpsideDown =UIDeviceOrientationPortraitUpsideDown,

   UIInterfaceOrientationLandscapeLeft      =UIDeviceOrientationLandscapeRight,

   UIInterfaceOrientationLandscapeRight     =UIDeviceOrientationLandscapeLeft

};

是否支持旋转

- (BOOL)shouldAutorotate

{

NSLog(@"%s",__FUNCTION__);

returnNO;

}

在旋转某一个方向时,是否支持旋转

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

{

NSLog(@"%s",__FUNCTION__);

returnNO;

}

将要旋转时走的方法,可以判断要转向的方向

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

{

NSLog(@"%s  %f",__FUNCTION__,duration);

}

视图将要布局子视图

window调整显示的view controller的bounds,由于view controller的bounds发生变化,将会触发viewWillLayoutSubviews 方法。

- (void)viewWillLayoutSubviews

{

NSLog(@"%s",__FUNCTION__);

}

视图完成布局子视图

- (void)viewDidLayoutSubviews

{

NSLog(@"%s",__FUNCTION__);

}

接着当前view controller的willAnimateRotationToInterfaceOrientation:duration: 方法将会被调用。系统将会把该方法中执行的所有属性变化放到动animation block中。

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

{

NSLog(@"%s  %f",__FUNCTION__,duration);

}

旋转完成执行的方法

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

{

NSLog(@"%s",__FUNCTION__);

}



文章标题:ios屏幕旋转
当前URL:http://cdkjz.cn/article/peghgs.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220