【发布时间】:2011-10-17 14:03:02
【问题描述】:
我是新手,所以对于我遇到的以下问题的任何建议将不胜感激。
我有一个应用程序,您可以在其中输入许多项目,然后在随后的表格视图中,它们将全部加载,我可以使用 uislider 为每个项目分配一个值。
如果我知道我将拥有的项目的确切数量,我知道如何跟踪和保存这些值,但鉴于我必须跟踪的 uislider 值的数量取决于输入的项目数量,我不知道该去哪里.
到目前为止,在我的 sliderValueChanged 方法中,我有以下内容可以让我跟踪每个 uislider 子视图:
- (IBAction)sliderChangedValues:(id)sender {
UISlider *slider = (UISlider *)sender;
CGPoint correctedPoint =
[slider convertPoint:slider.bounds.origin toView:self.tableView];
NSIndexPath *indexPath =
[self.tableView indexPathForRowAtPoint:correctedPoint];
NSLog(@"Using slider in row %d", indexPath.row);
}
这是我用于加载单元格的 cellForRowAtIndexPath 方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath {
Criteria *myCriteria = [criteriasRankingArray objectAtIndex:indexPath.row];
static NSString *CellIdentifier = @"CriteriaRankingCell";
OptionsDetailViewCell *cell = (OptionsDetailViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[self.cellNib instantiateWithOwner:self options:nil];
cell = optionsCell;
self.optionsCell = nil;
}
cell.criteriaRankSlider.minimumValue = 1.00;
cell.criteriaRankSlider.maximumValue = [criteriasRankingArray count];
cell.criteriaRankSlider.continuous = YES;
cell.criteriaNameLabel.text = [NSString stringWithFormat:@"%@", myCriteria.criteriaName];
cell.criteriaRankSlider.value = [myCriteria.criteriaRank floatValue];
return cell;
}
如何跟踪每个值,然后在哪里设置每个滑块值并保存到上下文?
【问题讨论】:
标签: iphone core-data uitableview uislider