Last active
August 29, 2015 14:04
-
-
Save zzz6519003/c290ad8afbfce7d67770 to your computer and use it in GitHub Desktop.
为什么不应该把cell给替换成view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----------------- | |
C | | |
| | |
------------ | | |
A | | | |
a | | | |
| | | |
b | | |
------------ | | |
B | | |
| | | |
c | | |
| | | |
| | |
------------ | | |
----------------- | |
上图为刘总的想法,如果这么做 | |
1. 设想如果产品说要在b下插入一个view,这样你得先改变A的height,再改变B的y,再改变C的height。 | |
2. 设想如果产品说要把b隐藏掉,你得先把A的height改了,再改变B的y,再改变C的height。 | |
3. 如果要隐藏a,你得先改变b的y,A的height,再改变B height C height | |
如果保持现在的做法上述问题都没有(只要在代理设height就搞定了),有个特别值得一提的好处是: | |
如果产品要把b隐藏掉,我只需要在delegate里把height设成0。 | |
产品说又要b了,我们再把height设回去ok了。 | |
这样做其实还有更大的好处在于,如果我们尽量用框架提供的方法,后人的维护将相当简单,因为那些代理方法他们本来就知道是干什么的。 | |
还有一种科学的做法是Autolayout,不过现在其实写的人不多。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
我认为我这个页面很简单,只有几个cell而已。这种情况下用框架提供的方法比较适合。
刘总头像好帅。。。