automaticallyAdjustsScrollViewInsets 使用
automaticallyAdjustsScrollViewInsets(个人认为iOS7中略坑爹的属性)
@当我们在一个UIViewController中同时创建2个tableView的时候,如果把它们的frame中的Y坐标设置为一样,你可能会发现它们的位置并没有达到你想要的结果.比如第一tableView个frame(0,0,320,568),另一个也frame(0,0,320,568),结果会发现第二个tableView的第一行数据被导航栏遮挡了,以至于我们不得已把第二个frame改成(0,64,320,568-64),虽然效果变成了我们想要的,但是却不知道这是什么原因.......
另一说:
self.automaticallyAdjustsScrollViewInsets = NO;
看这个UIViewController的这个属性你就明白了,此属性默认为YES,这样UIViewController下如果只有一个UIScollView或者其子类,那么会自动留出空白,让scollview滚动经过各种bar下面时能隐约看到内容。但是每个UIViewController只能有唯一一个UIScollView或者其子类,如果超过一个,需要将此属性设置为NO,自己去控制留白以及坐标问题。
其实这一切都是automaticallyAdjustsScrollViewInsets在作怪,我们可以先看一下官方文档中对它的描述:
automaticallyAdjustsScrollViewInsets
Specifies whether or not the view controller should automatically adjust its scroll view insets.
@property(nonatomic, assign) BOOL automaticallyAdjustsScrollViewInsets
Discussion
Default value is YES, which allows the view controller to adjust its scroll view insets in response to the screen areas consumed by the status bar, navigation bar, and toolbar or tab bar. Set toNO if you want to manage scroll view inset adjustments yourself, such as when there is more than one scroll view in the view hierarchy.
Availability
- Available in iOS 7.0 and later.
Declared In
UIViewController.h
哈哈,由此可见,当我们一个界面有多个tableView之类的,要将它设置为NO,完全由自己手动来布局,就不会错乱了.
相关文章
- 使用pymysql对数据进行增删改查 回滚
- Spring 事务管理的使用
- SVN版本号管理工具使用中常见的代码提交冲突问题的解决方法
- 3.2在Activiti Explorer中使用Activiti Modeler
- 使用GCC和GNU Binutils编写能在x86实模式运行的16位代码
- MindManager使用教程
- MVC对集合筛选,不使用Where(),而使用FindAll()
- bootstrap2.3.2常用标签的使用
- assert的使用
- 使用IntelliJ IDEA和Maven构建Java web项目并打包部署
- Smarty之html_options使用心得
- ESP8266接入腾讯云开发笔记(三)通过串口助手使用AT指令将ESP-12F接入腾讯云测试
- 【一】注入框架RoboGuice使用:(A brief example of what RoboGuice does)
- Git 使用教程 之 Git常见错误及解决方法整理
- awk基本使用方法简单介绍
- VirtualBox安装及使用说明和虚拟机安装XP系统图文教程
- 编程参考 - GNU编译使用的命令行选项: 选择语言标准的“-std=“