iPad/iPhone multiple orientations best practice?

前端 未结 3 1235
孤街浪徒
孤街浪徒 2021-01-03 07:29

I\'d like to convert my views to work for any orientation (especially since it recommended for iPad). I\'ve been using IB to lay things out, and am not sure how to best pro

3条回答
  •  借酒劲吻你
    2021-01-03 08:01

    Looking at the above code, using two views - I like it. To respond to the remark of "now I have to maintain two references - well, not there is a work around - use "references" (my term).

    Name the views and outlets with prefixes of l and p, then define "pseudo" ivars with the base names you use now. When you first viewDidLoad (or elsewhere) set all "pseudo" ivars to the l or p varient. When you switch orientation, you just set the pseudo ones to the other orientation (along with other ops).

    In viewDidUnload and dealloc, only reference the l and p item - the "real" IBOutlets - and simply nil the pseudo ivars out. Make it even more ugly - l_no_no_no_ or something in front of the real IBOutlets so you don't inadvertently use one.

    If you make the pseudo ivars properties, use ASSIGN not RETAIN !!!

提交回复
热议问题