objective c - iOS: How to dynamically change DetailView in SplitView template? -
i've got splitview template project. want change detailview on user selecting item in rootviewcontroller.
in fact can't change what's inside view (detailview) it's done in template (when check "use core data storage" on creating project). want switch between whole views.
i've tried that:
appdelegate *appdelegate = [uiapplication sharedapplication].delegate; [appdelegate.detailviewcontroller setview:curretndetailviewcontroller.view]; appdelegate.detailviewcontroller = currentdetailviewcontroller; by way don't understand why need line#2 (..setview:..)? why assigning detailviewcontroller (line#3) not enough? - code looks awful=(
but anyway doesn't work want. except detailview disappears. i've changed main view, not detailviewcontroller's
i guess should change in splitviewcontroller didn't find out what=(
thanks attention.
i had questions week ago , got little in forum. hope can change you.
first did know apple has multi detail view example? here apple examples
you have understand splitviewcontroller idea of apple doing. think of splitview controller container within device window. container has 2 compartments, thin left hand side bigger right hand side. change on either side have replace compartment compartment of similar size , nature. cannot put in there compartment not fit or fancy cause not fit.
in technical talk find below code in example. splitview controller has array of 2 views , can change views in array. in array 2 views left called navigationcontroller , right detailviewcontroller. if alloc , initiate view , add either of these 2 view replace current view in splitviewcontroller.
nsarray *viewcontrollers = [[nsarray alloc] initwithobjects:self.navigationcontroller, detailviewcontroller, nil]; splitviewcontroller.viewcontrollers = viewcontrollers; now second part question - think left hand side want able able choose , able change right hand side....am right?
i have read 3 different ways of doing , not seen says 1 better other.
- set notification - whereby when click on on left noticiation sent right hand side.
- when start bottom or root view of left hand side have reference right hand side, if add subviews etc left hand side pass along reference right hand side.
- the way did set protocol in appdelegate or in rootview delegate, on view want talk right hand side uses protocol , right hand side implements protocol. last 1 learnt preferred method of getting modal views talk other views.
i not expert have not added code each of 3 choices above, suggest little bit of googling topics , see examples. if stuck on 1 let me know , try find again google examples have found in past. least complicated think no.1.
i hope going in right direction.
Comments
Post a Comment