ios - Data transfer between child tabs in a Tab bar controller -
my tab bar controller has 4 tabs, have 6 textfields in vc1 , want use data entered display labels in vc2, vc3 & vc4. have read adding data tabbarcontroller subclass , using in rest of vc's stuck on implementation. i'm absolute beginner , code or links implementation of code great.
try this:
i have created uitabbarcontroller
2 child controllers tab1viewcontroller
, tab2viewcontroller
.
screenshot of storyboard:
code:
class tab1viewcontroller: uiviewcontroller { @iboutlet weak var testtextfield: uitextfield! override func viewdidload() { super.viewdidload() } } class tab2viewcontroller: uiviewcontroller { @iboutlet weak var testlabel: uilabel! override func viewdidload() { super.viewdidload() } override func viewwillappear(_ animated: bool) { super.viewwillappear(animated) let tab1controller = self.tabbarcontroller?.viewcontrollers?.first as! tab1viewcontroller self.testlabel.text = tab1controller.testtextfield.text } }
similarly can create 4 tabs , other textfields.
for more refer : how pass data tab bar controller 1 of tabs?
Comments
Post a Comment