iOS界面自动旋转与自适应布局全解析
1. 指定旋转支持
在开发iOS应用时,我们常常需要处理界面的旋转问题。当你打开 BIDViewController.m 文件,会看到模板为我们提供了一个 shouldAutorotateToInterfaceOrientation: 方法:
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
这个方法是iOS用来询问视图控制器是否允许旋转到特定方向的。iOS设备有四种常见的握持方向,对应四个预定义的方向常量:
- UIInterfaceOrientationPortrait
- UIInterfaceOrientationPortraitUpsideDown
- UIInterfaceOrientationLandscapeLeft
- UIInterfaceOrientationLandscapeRight
对于iPhone项目,模板默认支持除倒
超级会员免费看
订阅专栏 解锁全文
63

被折叠的 条评论
为什么被折叠?



