iOS iphone formatting: What is best way to format page so it works on all screens? -
i have looked @ umpteen tutorials, google posts , questions on still struggling best way layout page iphone app.
part of problem many of tutorials , questions old , discuss ways may have been optimal @ time in past.
now, in may 2015, best-simplest way have things textfields , images layout display in common iphones i.e. iphone 4, 5, 6 , 6plus?
is necessary use constraints? i've gone down road found labor intensive?
can use blue lines recommend in stanford 193p tutorial? or there rule of thumb way layout picture or text box looks in multiple formats i.e. number of points or using blue lines.
storyboard in xcode 6.0 600x600 can tell lot of times lay out looks horrible in simulator. simulator not actual iphone.
thanks suggestions on right way this.
you have 2 choices; constraints or frame math. both have benefits , detriments.
the benefit of layout constraints can figure out universal relationships between subviews , superview. (e.g. it's 20 points leading , trailing edges or it's dead center x , y) once that, need write layout code once , work across device screen sizes. also, if ever plan support ipad or rotation on iphone, work take support functionality minimal. huge benefit if view's frame changes, take care of resizing , laying out of subviews can modify size of container example , not have reset of it's children's frames manually.
constraints "more modern" frame math , apple's preferred method.
the issue constraints code more verbose. views depend on superviews lay out. if done correctly works great. if make mistake adding constraints 1 view has potential trash else depends on it. once figured out advertises. getting point can be, in opinion, more complicated setting frames explicitly since there more moving parts.
frame math still has it's place sometimes. has benefit of being fast , relatively concise. when iphones had same sized displays worked great , if laying out in view guaranteed rect there's no reason need avoid setting frames.
the problem frames expected support devices run ios 8. if laying out frames means have write 5 different sets of layout code support 4s, 5, 6, 6+, , ipad , 5 more sets if want them rotate. isn't tenable.
in end comes down whether or not containing view has guaranteed height , width. if answer yes (like laying out inside of collection view cell static width , height example), have no problem leaning towards frames. if not, auto layout way go.
Comments
Post a Comment