please clear confusions regarding uiviewcontroller
i found article abusing uiviewcontroller
, here links link1 & link2
and summarised points
this author's (and apple’s) advice in nutshell:
- one (and one) view controller should responsible whole hierarchy (or screenful) of uiviews.
- mostly, should use 1 view controller per screen.
rootviewcontroller
of currentuiwindow
shoulduiviewcontroller
visible view. - each different screen should have different view controller i.e. 1 controller should not control more 1 screen.
- you should not nest custom
uiviewcontrollers
within view hierarchy. - if more 1
uiviewcontroller
hangs off application’suiwindow
, 1 of these messages changes in orientation. other(s) not these messages. - nested
uiviewcontrollers
not guaranteed, or likely, receive messages changes in orientation or lifecycle messages suchviewdidappear:
,viewwillappear:
,viewdiddisappear:
,viewwilldisappear:
though inherituiviewcontroller
. topmostuiviewcontroller
these messages.
please clear point number 2 , 3 because when use uinavigationcontroller
or uitabbarcontroller
use multiple subclasses of uiviewcontroller
. , ios device has 1 screen.....
this article abusing uiviewcontroller highlight apple suggestion
note: if want divide view hierarchy multiple subareas , manage each 1 separately, use generic controller objects (custom objects descending nsobject) instead of view controller objects manage each subarea. use single view controller object manage generic controller objects.
and in apple docs under heading of coordinating efforts between view controllers
apple saying
few ios apps show single screenful of content. instead, show content when first launched , show , hide other content in response user actions. these transitions provide single unified user interface display lot of content, not @ once.....
my requirement not use container or modal or popover, want manual management, have 2 view controllers vc1
& vc2
. vc1
root view controller want switch/transit/move vc2
should do?
vc1
should subclass ofuiviewcontroller
,vc2
should subclass ofnsobject
manage particular view invc1
hierarchy?(the show hide thing apple doc).vc2
can subclass ofuiviewcontroller
, removevc1
root view , addvc2
root view?
or correct way?
container view controllers (like uinavigationcontroller) allow working around one-vc-per-screen rule. since ios 5, developers have been able , allowed write our own container controllers (which aren't different normal vcs). means writing non-vc controller objects less necessary used be.
in situation, want replace root view controller, option 2 makes more sense. use vcs can, , non-vc controller objects when can't. since you're replacing whole screen's content, switching uiwindow rootviewcontroller
makes sense (edit: alternately, many devs use navigation controller present second view, because it's simple , convenient).
Comments
Post a Comment