Passing data back from embedded view controller
By : user2252879
Date : March 29 2020, 07:55 AM
This might help you I have a UIViewController which embedded inside another UIViewController. In this child view controller, there are two UITextFields which lets the user to enter some data. , You need to typecast before using it. Check with: code :
let myObj : MyClass = self.childViewControllers.last as ? MyClass;
let textfield: UITextField = myObj?.usernameTextField! as UITextField;
|
Embedded directive not passing its form data to parent controller
By : gpaume
Date : March 29 2020, 07:55 AM
|
How can I pass data from a parent view controller to an embedded view controller in Swift?
By : Linde_98
Date : March 29 2020, 07:55 AM
wish helps you A way to achiеve this is to get the child view controller instance in the parent's viewDidLoad. It appears that the parent's viewDidLoad: gets called after the child's viewDidLoad:, which means the label is already created in the child's view. code :
override func viewDidLoad() {
super.viewDidLoad()
if let childVC = self.childViewControllers.first as? ChildVC {
childVC.someLabel.text = "I'm here. Aye-aye."
}
}
|
Passing Data between view Controllers Using a segue from a view embedded in a navigation controller to a tabbarcontrolle
By : Ahad Ali
Date : March 29 2020, 07:55 AM
this will help This is my view controller where you can check that I am sending 5 to tabbar first viewcontroller: code :
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.performSegue(withIdentifier: "segueIdentifier", sender: self)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let barViewControllers = segue.destination as! UITabBarController
let destinationNv = barViewControllers.viewControllers?[0] as! UINavigationController
let destinationViewController = destinationNv.viewControllers[0] as! FirstViewController
destinationViewController.currentBalance = 5
}
}
class FirstViewController: UIViewController {
var currentBalance = 0
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
print(currentBalance)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
|
Passing Data From Parent View Controller to Child View Controller Swift 4
By : Mariano
Date : March 29 2020, 07:55 AM
it fixes the issue I am trying to send data from parent view controller (Container View) to its child view controller. , Try this code code :
if let controller = (self.childViewControllers.filter {$0 is urChildController}).first {
// assign ur parsed data of parent controller to your child controller
controller.dict = self.urResponseDict
}
|