'UIUISegmentedControls overlap inside UITableView cells after scrolling
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
, but if l scroll down and up several times (5-10), my segmentedControls can overlap:
Seems like UISegmentedControl from second row is created in the first and vice versa. How can I avoid it?
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Pradeep Kashyap |


