gpt4 book ai didi

ios - UITableViewCells 重复内容的问题

转载 作者:行者123 更新时间:2023-11-30 11:16:42 25 4
gpt4 key购买 nike

我的应用程序向用户显示本地巴士出发时间,但是当夜间巴士在滚动后开始在其他服务中显示红色“N”时(如下方屏幕截图所示),另外路线编号开始错误。滚动时,其余时间路线编号都是正确的,仅当夜间巴士出现时

After opening the app

Night Buses at the bottom of the Table

Scrolling back up the app

这是我为设置路线编号而执行的代码

case "N3", "N7", "N11","N16","N22","N25","N26","N30","N31","N34", "N37","N44","N98", "N106","N113","N124":

var route = NSMutableAttributedString()

route = NSMutableAttributedString(string: departureRoutes[0].rawString()!)

route.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor.red, range: NSRange(location:0,length:1))

route.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor.white, range: NSRange(location:1,length:(departureRoutes[0].string?.count)! - 1))

cell.route.setAttributedTitle(route, for: .normal)

default :

cell.route.tintColor = routeColor(routeno: departureRoutes[0].rawString()!)

最佳答案

Mohamed Mostafa 在评论中建议的解决方案是重置 UIButton 的值并使用再次设置该值

cell.route.setAttributedTitle(NSMutableAttributedString(string: "\(departureRoutes[indexPath.row + 1])"), for: .normal)

然后执行此后的切换代码

关于ios - UITableViewCells 重复内容的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51679033/

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