storyboard和xib的各种问题

1.prepareFoSegue注意问题
使用该方法设置的值, 必须要 viewWillApear之后用

 

2.storayboard的使用autolayout, constant = -16, 刚好在frame上为0

2.1 ipad上需要 constant = -24 才能在frame上为 0 

3. storayboard 使用 autolayout top = -64 相当于 frame上 64

                 top = -128 相当于 frame上 0

4.cell xib中 使用 autolayout constant = -8,放好在frame上0

 

去掉constaint to margin 则不会有上述反应

继续选择TextContainer view,点击底部的 Pin 按钮弹出 Add New Constraints 窗口,在Spacing to nearest neighbor 面板中设置左、右、底部的约束,将值设置为0,然后点击Add 3 Constraints 按钮添加约束。这里要注意的是,在设置约束时要将 Constrain to margins 选项的勾去掉,这样可以避免TextContainer view产生内边距:

图片

2. 使用拉控件 frame.origion.y = 0, 如果有导航栏的话, 实际坐标是64, 如果没有则为 20

3. 使用代码 frame.origion.y = 0 , 不管有无导航栏都是 0 

 

二.xib的各种问题

2.1. xib中, 于self.view 下的uiscrollview/uitableview

条件1: self.view有且只有一个子视图, 并且这个子视图必须是uiscrollview或者uiscrollview的子类

结果: y坐标是基于导航栏64开始的

2.2. xib中 也是有constraint to magins 8px

 

三.autolayout的问题

3.1. autolayout虽然可以解决屏幕适配的很多问题, 但是缺很笨重

3.1.1. 不能获取视图的frame, 在viewwillappear: self.view的正确frame才会被给出, 

直到viewdidappear, xib/storyborad的frame才被全部确定

3.1.2. viewDidLayoutSubviews viewwilllayoutsubviews 这几个方法会被调用多次, 所以不能在这几个方法上创建视图

3.1.3. autolayout约束难以被修改, 不能重复约束, 难以控制

 

posted @ 2015-04-02 21:47  apem  阅读(338)  评论(0编辑  收藏  举报