The text below here uses a uitextield and saves it to a label. Lets say this is view controller A. I am passing through a to b view controller using a simple button
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var text: UITextField!
@IBOutlet weak var labelz: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func ritaOra(_ sender: Any) {
labelz.text = text.text
UserDefaults.standard.set(labelz.text, forKey: "myName")
text.text = ""
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewDidAppear(_ animated: Bool) {
if let x = UserDefaults.standard.object(forKey: "myName") as? String
{
labelz.text = x
}
}
This code below is what I use in a camera. Lets say this is view controller b.
let text = "Python"
let label = UILabel(frame: CGRect(x: 125, y: 400, width: self.view.frame.width, height: 300))
label.font = UIFont(name: label.font.fontName, size: 122)
label.textColor = UIColor.blue
label.alpha = 0.3
label.text = text
How can I take the textview in view controller a and place into where let text = “Python” (in view controller b) is currently.