触发按钮以更改 swift3 xcode 8 ios 10 中 UITextView 中的文本 [英] Trigger button to change text in UITextView in swift3 xcode 8 ios 10

查看:29
本文介绍了触发按钮以更改 swift3 xcode 8 ios 10 中 UITextView 中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 xcode 的新手,一直在解决这个问题,因为在网上尝试了几个示例代码示例后,没有任何效果.

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?

我的代码如下:

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"
    } 
}

推荐答案

你可以试试下面的代码,你肯定会得到你期望的输出,并确保你将故事板连接到你的视图控制器类,你按钮动作和文本文件插座可以适当地给IBActions和IBOutlets

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

未点击按钮前的输出

点击按钮后

这篇关于触发按钮以更改 swift3 xcode 8 ios 10 中 UITextView 中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆