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.
rootviewcontrollerof currentuiwindowshoulduiviewcontrollervisible view. - each different screen should have different view controller i.e. 1 controller should not control more 1 screen.
- you should not nest custom
uiviewcontrollerswithin view hierarchy. - if more 1
uiviewcontrollerhangs off application’suiwindow, 1 of these messages changes in orientation. other(s) not these messages. - nested
uiviewcontrollersnot guaranteed, or likely, receive messages changes in orientation or lifecycle messages suchviewdidappear:,viewwillappear:,viewdiddisappear:,viewwilldisappear:though inherituiviewcontroller. topmostuiviewcontrollerthese 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?
vc1should subclass ofuiviewcontroller,vc2should subclass ofnsobjectmanage particular view invc1hierarchy?(the show hide thing apple doc).vc2can subclass ofuiviewcontroller, removevc1root view , addvc2root 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