滚动后,UiuiseMentedControls在UitableView单元格内重叠

发布于 2025-01-30 08:30:48 字数 1137 浏览 1 评论 0原文

我有一些单元格(设置)。

在单元格内部,我以编程方式创建一个UiseMentedControl:

class SettingsCell: UITableViewCell { 
var segDist : UISegmentedControl? = nil ...

var sectionType: SectionType?{
    didSet{
        guard let sectionType = sectionType else {return}
        
        textLabel?.text = sectionType.description
 

        switch sectionType.containsSegmented{
            case .DISTANCE:
            if (segDist == nil){
                segDist = makeSegmentedControl(items:["yrds","m"], segmentIndex:  SettingsManager.shared.getRangeUnitIndex() - 1, action: #selector(handleSegmentedControlActionDistance))}

为每个单元格创建依此类推。一切正常

“在此处输入图像描述”

,但是如果L向下滚动几次(5-10),我的分割controls可以重叠:

“在此处entrape

似乎在第二行中创建了uisegringedcontrol首先,反之亦然。我该如何避免它?

I have UITableView with some cells (settings).

Inside the cell I create a UISegmentedControl programmatically:

class SettingsCell: UITableViewCell { 
var segDist : UISegmentedControl? = nil ...

var sectionType: SectionType?{
    didSet{
        guard let sectionType = sectionType else {return}
        
        textLabel?.text = sectionType.description
 

        switch sectionType.containsSegmented{
            case .DISTANCE:
            if (segDist == nil){
                segDist = makeSegmentedControl(items:["yrds","m"], segmentIndex:  SettingsManager.shared.getRangeUnitIndex() - 1, action: #selector(handleSegmentedControlActionDistance))}

and so on for every cell. Everything works fine

enter image description here

, but if l scroll down and up several times (5-10), my segmentedControls can overlap:

enter image description here

Seems like UISegmentedControl from second row is created in the first and vice versa. How can I avoid it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

牵你手 2025-02-06 08:30:49

在您的单元格UI或代码中创建段控件,以便将其获取
Donmag提及的每个新单元格的刷新

如果您需要该设置中的帮助,请分享您的实施

Create segment control in your cell UI or code so that it will get
refresh for each new cell as donMag mention

if you need help in that setup please share your implementation

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文