|
|
|
|
|
by nodemaker
5229 days ago
|
|
I think this way of laying out subviews is a functionally incomplete approach and it more often than not makes you write more code than it really abstracts. To be honest this is in fact one reason most iOS developers dont like Android or Java Swing.Because what really happens is that you think of something really cool and then you realize that its not really linear or grid or rectangular or even box.At that point learning how to layout subviews with co-ordinates is too much work and you just go with a shitty box layout instead.This has happened to me so many times while using java swing that I am now (wrongly) biased against java for life. For example what if I want to layout my subviews in a circular fashion around the centre of the parent view.Or what if my subviews are cards which are seperated from the previous card with exponentially increasing distances. On iOS the simple way to layout subviews is by quite simply setting their frames relative to the frame of the parent view in the layoutSubviews method.To take care of different screen sizes and orientations all you have to do is the set the autoresizing mask correctly.Thats it! That's like seven lines of code for three subviews and it is functionally complete. |
|