3

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"
    } 
}
Miknash
  • 7,888
  • 3
  • 34
  • 46
Alyak
  • 39
  • 1
  • 1
    What behaviour do you expect? Have you attached an event to the button ? I suspect you used the storyboard to link TalkbuttonTapped to Talkbutton – La masse Dec 25 '16 at 20:40
  • OMG, thank you! I didn't link the button to the IBAction, that's why. It's a step not mentioned in several tutorials I looked at, perhaps it was assumed to be obvious. – Alyak Dec 25 '16 at 20:59
  • Maybe you want to use `UILabel` for `Writingboard`, instead of `UITextView`. – f_qi Mar 27 '17 at 13:51

1 Answers1

1

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