swift - How can I get the contents of the text box below and display the retrieved text on the label when I press the button?
解决方案
我想您已经将文本框的引用创建为TextView
. 现在您需要IBOutlet
为标签创建一个新标签。获得对标签的引用后,您可以从 textview 获取文本值并将其显示在标签中。
@IBAction func display(_sender) {
self.labelView.text = self.TextView.text
//if you want to clear the textview
self.TextView.text = ""
}
推荐阅读
- javascript - 如果值相等,则按字母顺序对 Hashmap 进行排序
- express - 为 ApolloServer 向上游服务发出的每个请求添加标头
- grafana - 时间序列图的 Grafana 自定义“时间”字段
- php - 困惑为什么 php 代码没有按预期工作。使用 if( x 和 y) {}
- java - 使用 Maven 动态加载类的 Jar 着色
- sql - Spark SQL 正则表达式提取日期、文件名和品牌
- python - Discord Currency Bot discord.py 需要帮助
- python - 自动实例化/加载多个消费者和生产者
- css - 如何在 razor pages 应用程序中安装和引用 bootstrap 版本 5
- node.js - 如何创建一个可以在群组中添加和删除用户的 Facebook Messenger 机器人