Updating UISlider inside UITableViewCell

I have a custom UITableViewCell containing a UISlider and UILabel control that shows the current text value for the position of the slider. I want to update the shortcut while dragging the slider. Here are the basic elements.

cellForRowAtIndexPath: This procedure accepts data and updates the value of the slider and its associated label.

sliderValueChanged: This procedure reads the value of the slider that updates the data. Then it calls [table reloadData] to update the label.

Problem: Somehow reloadData interrupts the flow of updates. If I replace NSLog instead of reloadData, I get a good stream of updates showing the value of the slider. In an attempt to prevent the loop, I set it in tests so as not to set the value of the slider or call reloadData if the value was not different. This is not a fix.

Any help would be greatly appreciated!

+4
source share
2 answers

The problem is caused by [table reloadData], which seems to be creating a new Cell object, so updates to the same slider do not work. The correct implementation was to get the reference cell inside the sliderValueChanged routine and set the label from there. Set the tag on the slider to indicate the line, and then call the method to get the cell with the pointer.

+6
source

Such things have happened to me. Go to the build settings and find the compiler flag called β€œEnable floating point library calls.” Make sure it is disabled. See if this helps you.

+1
source

All Articles