Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger button to change text in UITextView in swift3 xcode 8 ios 10

I'm new to xcode and am stuck on this problem, because after trying several sample code examples online, nothing works.

Could you help me figure out what the problem is?

My code below:

import UIKit

class ViewController: UIViewController {
    @IBOutlet weak var Writingboard: UITextView!
    @IBOutlet weak var Talkbutton: UIButton!

    @IBAction func TalkbuttonTapped(_ sender: AnyObject){
        Talkbutton.setTitle("Tap to Stop", for: .normal)
        Writingboard.text="talking"
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        //Talkbutton.isEnabled=true
        Writingboard.text="test the initializer"
    } 
}
like image 789
Alyak Avatar asked Feb 04 '26 11:02

Alyak


1 Answers

you can try this bellow code you definetly get the output what you expected and make sure you connect the story board to your view controller class you button action and textfiled outlets can give IBActions and IBOutlets properly

enter image description here

output before not button tapped enter image description here

After tapped the button

enter image description here

like image 107
Gangireddy Rami Reddy Avatar answered Feb 06 '26 05:02

Gangireddy Rami Reddy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!