ios - Segue instatiated ViewController with instantiateViewControllerWithIdentifier -
ios - Segue instatiated ViewController with instantiateViewControllerWithIdentifier -
is possible utilize segues in views of viewcontrollers instaniated instantiateviewcontrollerwithidentifier?
here minimal illustration of i'm trying (i need in biger project): in main storyboard have rootviewcontroller, secondviewcontroller storyboardid "secondviewcontrollerid" , thirdviewcontroller. secondviewcontroller connected thirdviewcontroller via button through show-segue.
in class of rootviewcontroller instantiate secondviewcontroller , set view subview of rootviewcontroller:
import uikit class viewcontroller: uiviewcontroller { override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. allow storyboard = uistoryboard(name: "main", bundle: nil); var vc = storyboard.instantiateviewcontrollerwithidentifier("secondviewcontrollerid") uiviewcontroller self.view.addsubview(vc.view) } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } }
when execute programm see correctly subview (secondviewcontroller). segue doesn't work anymore (when click on button don't thirdviewcontroller)
does has thought why?
(it not possible in project utilize secondviewcontroller without instantiateviewcontrollerwithidentifier because secondviewcontroller part of pageviewcontroller managing viewcontrollers via instantiateviewcontrollerwithidentifier )
you adding 1 view controller's view subview of view controller. default, taps , gestures handled main view controller , not passed on subsidiary vc - hence problem. there functions need phone call work. take @ apple docs here.
look @ section on "creating custom container view controllers". in summary, need wrap addsubview
method phone call self.addchildviewcontroller(vc)
, vc.didmovetoparentviewcontroller(self)
function calls.
ios swift segue viewcontroller
Comments
Post a Comment