Get value from a UISlider inside a Cell

I have a tableView with custom cells in it, each cell has a UISlider.

Now I want to create a method to get the values of those UISliders, but I don't know how to access each cell and its slider value.

Thanks in advance!

Answers


First add a tag to each slider so you no which slider is which:

slider.tag = 0 //Can be any unique integer

Then register a method for slider changes:

[slider addTarget:self action:@selector(sliderUpdate:) forControlEvents:UIControlEventValueChanged];

Finally in your method

-(void)sliderUpdate:(UISlider *)sender {
    int value = sender.value;
    int tag = sender.tag;
}

Tag will now be the same unique integer you used before. It is a way of identifying the element.


Need Your Help

UILabel Dynamic Font size keep breaking

ios xcode uilabel uifont adjustment

I Have CollectionViewCell that has only UILabel(Same bounds as cell).

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.