我在UITableView
的CustomCell中创建了一个步进器。但是,我希望只有在选择特定行时才能看到步进器。为此,我尝试了以下方法:
在tableView:cellForRowAtIndexPath:
cell.customStepper.hidden=NO;
并在tableView:didSelectRowAtIndexPath:
cell.customStepper.hidden=YES;
但是步进器仍然是隐藏的。我错过了什么?
答案 0 :(得分:0)
@interface BRNCategoryViewController ()
{
NSMutableArray *arySelectCategory;
NSMutableArray *aryCategory;
}
- (void) viewDidLoad
{
arySelectCategory=[NSMutableArray new];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return aryCategory.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
BRNCategoryCell *cell=[[BRNCategoryCell alloc]initWithOwner:self];
if ([arySelectCategory containsObject:[aryCategory objectAtIndex:indexPath.row]])
{
cell.customStepper.hidden = NO;
}
else
{
cell.customStepper.hidden = YES;
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if ([arySelectCategory containsObject:[aryCategory objectAtIndex:indexPath.row]])
{
[arySelectCategory removeObject:[aryCategory objectAtIndex:indexPath.row]];
}
else
{
[arySelectCategory addObject:[aryCategory objectAtIndex:indexPath.row]];
}
[tblEventCategory reloadData];
}
答案 1 :(得分:0)
在cellForRowAtIndexPath
cell.customStepper.hidden=YES;
并且
在didSelectRowAtIndexPath
VideosCell *cell = (VideosCell *)[tableView cellForRowAtIndexPath:indexPath];
cell.customStepper.hidden = NO;