ios - 在 Swift 中将文本添加到 TextView

标签 ios arrays for-loop swift

如何向标签或表格 View 添加文本,而不是更新标签/表格 View ?

var personArray: [Person] = [
Person(name: "Heine", sex: "Guy"),
Person(name: "Magnus", sex: "Girl"),
Person(name: "Sarah", sex: "Girl")
]

@IBOutlet weak var thePeople: UILabel!

func updatePeople()
{
    for peop in personArray{
        thePeople.text = ""
    }
}

最佳答案

thePeople.text = thePeople.text+"NewText"

或更短

thePeople.text += "NewText"

关于ios - 在 Swift 中将文本添加到 TextView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26968219/

相关文章:

iphone - 拦截 UIEvents 并将它们传递给父元素

ios - 更新 iOS 应用的应用内购买内容?

ios - UIVIew 将 anchor 设置为右边缘

ruby - 语法错误,意外的 tIVAR,应为 '('

javascript - 搜索 javascript 对象数组的更有效方法?

Swift:多次循环后更改随机数的算法

java - for循环内的for循环不执行

iOS:如何将 iPhone 设置链接到 PHPhotoLibrary 权限

c - 如何使用 "++"操作来增加C中结构中char数组的指针?

c# - 随机数生成循环生成相同的数字