gpt4 book ai didi

swift - 如何对 UITableViewCell 中的 TextView 中的数字进行排序?

转载 作者:行者123 更新时间:2023-11-28 08:06:46 24 4
gpt4 key购买 nike

我在显示特定评级的 UITableViewCell 中有一个 UITextView。如何以 TextView 按从高到低的顺序排序的方式对 UITableView 进行排序?这是我的文本字段的代码,以备不时之需:

let scoreText = UITextView()
scoreText.font = UIFont.systemFont(ofSize: 13.5)
scoreText.text = (String(userRating)) + " ✨"
scoreText.textColor = UIColor.gray
scoreText.textAlignment = NSTextAlignment.right
scoreText.translatesAutoresizingMaskIntoConstraints = false

最佳答案

这不是UITextView的问题。 UITableView 的顺序应符合数据源的顺序。例如,

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// In this case YOUR_DATA_LIST needs to be sorted beforehand.
return YOUR_DATA_LIST.count
}

关于swift - 如何对 UITableViewCell 中的 TextView 中的数字进行排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44869435/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com