uiviewcontroller - How to create a container/child viewcontroller relationship in interface builder -


to create code parent/child relationship between 2 view controllers it's matter of doing like:

[self addchildviewcontroller:childviewcontroller]; [self.view addsubview:childviewcontroller.view]; 

where self parent view controller.
but, what if want create same relationship interface builder?
or in other words: there way re-create behavior of method addchildviewcontroller using interface builder?
didn't find lot of documentation that, here old unresolved post topic: https://devforums.apple.com/message/455758#455758

without setting addchildviewcontroller relationship, none of rotation methods forwarded child view controller, here question come from.

this i've done in ib:

  1. drag , dropped "view controller" object "object library" panel "objects" panel
  2. in identity inspector i've changed class uiviewcontroller subclass ("items view controller")
  3. connected view outlet controller
  4. connected other required outlets controller (list name, table view)

the first "view" object in picture view of parent view controller, instead highlighted "view" view of child view controller ("item view controller").

enter image description here

the container controller retain child instance through additional iboutlet:

@property (nonatomic, strong) iboutlet itemsviewcontroller *itemsviewcontroller; 

thanks


update 1: if manually set parent/child relationship in viewdidload of container controller, rotation methods correctly forwarded child.

[self addchildviewcontroller:self.itemsviewcontroller]; 

but don't know if correct way of doing that, since using ib.


update 2: @micantox hint use "container view" in object library, have converted xib file storyboard , child view controller added parent, don't have add manually code addchildviewcontroller , rotation methods forwarded expected.
"container view" implements embed segue , supported ios 6.
updated screenshot storyboard:

enter image description here

the right way of creating container views child view controllers through use of object "container view" in object library. dragging 1 in view controller's scene create new scene child view controller can managed separately the parent view controller.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -