i newbie swift developer. receive advice experts on how solve following problem facing.
i trying embed in uiviewcontroller 2 child views controller , display both of them at same time in uiviewcontroller, parent view controller.
these 2 child view controllers both uitableviewcontrollers: first 1 table view 2 sections , 3 rows per each section, second child view table displays data dynamically.
using code below managed load , display each uitableviewcontroller can't display them both @ same time 1 below other. there way can solve problem?
thank muck patience , kindness.
class viewcontroller: uiviewcontroller { override func viewdidload() { super.viewdidload() let storyboard = uistoryboard(name: "main", bundle: nil) let firsttable = storyboard.instantiateviewcontrollerwithidentifier("firsttable") as! uinavigationcontroller let thirdtable = storyboard.instantiateviewcontrollerwithidentifier("thirdtable") as! uinavigationcontroller self.addchildviewcontroller(firsttable) firsttable.view.frame = self.view.bounds self.view.addsubview(firsttable.view) firsttable.didmovetoparentviewcontroller(self) self.addchildviewcontroller(thirdtable) thirdtable.view.frame = self.view.bounds self.view.addsubview(thirdtable.view) thirdtable.didmovetoparentviewcontroller(self) } }
in order show multiple uiviewcontrollers on same uiviewcontroller, apple recommends using container views (https://developer.apple.com/library/ios/featuredarticles/viewcontrollerpgforiphoneos/creatingcustomcontainerviewcontrollers/creatingcustomcontainerviewcontrollers.html). in essence, function child uiviewcontroller's view target. way can have multiple uiviewcontroller views on single uiviewcontroller.
however, sure need 2 separate controllers table views? if can away single controller 2 tableviews, i'd recommend using uiviewcontroller instead of uitableviewcontroller, add 2 uitableviews manually , add required datasource , delegate methods uiviewcontroller.
Comments
Post a Comment