UISlider Update inside UITableViewCell

谁说胖子不能爱 提交于 2019-12-23 13:25:10

问题


I have a custom UITableViewCell that contains a UISlider control and a UILabel which shows the current text value for the slider position. I want to update the label as the slider knob is dragged. Here are the basic elements.

cellForRowAtIndexPath: This routine takes data and updates the slider value and the label associated with it.

sliderValueChanged: This routine reads the slider value updates the data. It then calls [table reloadData] so the label gets updated.

Problem: Somehow the reloadData is interrupting the flow of updates. If I substitute NSLog instead of reloadData I get a nice stream of updates showing the value of the slider. In an attempt to prevent looping I put in tests to not set the slider value or call reloadData unless the value was different. That didn't fix things.

Any help would be greatly appreciated!


回答1:


The problem is being caused by the [table reloadData] which appears to be creating a new Cell object so updates the same slider aren't working. The correct implementation was to get the referenced cell inside the sliderValueChanged routine and set the label from there. Set a tag to the slider to indicate the row and then call the method to get the cell with the index path.




回答2:


Stuff like this happened to me. Go to build settings and look for a compiler flagged called "Enable floating point library calls". Make sure it's disabled. See if that helps you.



来源:https://stackoverflow.com/questions/1252781/uislider-update-inside-uitableviewcell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!