当我们在tableview中选择特定行时,如何取消隐藏步进器

时间:2015-04-08 12:01:17

标签: ios iphone uitableview uistepper

我在UITableView的CustomCell中创建了一个步进器。但是,我希望只有在选择特定行时才能看到步进器。为此,我尝试了以下方法:

tableView:cellForRowAtIndexPath:

cell.customStepper.hidden=NO;

并在tableView:didSelectRowAtIndexPath:

cell.customStepper.hidden=YES;

但是步进器仍然是隐藏的。我错过了什么?

2 个答案:

答案 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;