ios - How to pass data from ViewController to embed View Controller -
i have view controller, user taps button , moves second view, , want pass data it, second view has navigation view controller, prepareforsegue() doesn't work here. shall pass data navigation view , second view or else?
according this: https://developer.apple.com/library/prerelease/ios/documentation/uikit/reference/uinavigationcontroller_class/#//apple_ref/occ/instp/uinavigationcontroller/topviewcontroller , following solution more correct: use "topviewcontroller" of uinavitaioncontroller.
override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { let segueid = segue.identifier ?? "" switch segueid { case "tomynextvc": let nc = segue.destinationviewcontroller as! uinavigationcontroller let destinationvc = nc.topviewcontroller as! mynextviewcontroller destinationvc.vartopass = myvartopass default: break } }
Comments
Post a Comment