Reputation: 183
I'm kind of new to Swift programming, so this question might look silly!
I have a new viewController named InfoViewController and I have connected it to the visual view controller in main.storyboard as the figure below:
As you can see, the view controller in main.storyboard is connected to InfoViewController.swift
However, when I insert the UITextView into the InfoViewController.swift, it does not recognize it as the following pic.
What is the problem, any help is highly appreciated 😊
Upvotes: 2
Views: 43
Reputation: 7669
You cannot access the outlet property on the from outside method. In viewDidLoad method you can easily access the myText
outLet.
override func viewDidLoad(){
super.viewDidLoad()
myText.text = "something new"
}
Upvotes: 0
Reputation: 39
You can't just throw code inside the view... swift is function based... so you might want to create a function to call myText Label inside...
create this function on your class:
function changeMyLabelText(){
self.myLabel.setText("New Text")
}
And call it inside viewDidLoad method with
self.changeMyLabelText()
Upvotes: 1