有2个tableview ,atableview 把一个数组传到Btableview里面,然后在
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
方法中对比atableview的 button.tag 如果之前的相同的button.tag就回隐藏某一个btn.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [NSString stringWithFormat:@"B2Cell%d%d", [indexPath section], [indexPath row]];
//以indexPath来唯一确定cell
    UITableViewCell *Cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; //出列可重用的cell
    if (Cell == nil) {
        Cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    NSInteger Row = [indexPath row];
    Cell.textLabel.text = [B2Array objectAtIndex:Row];
    Cell.textLabel.numberOfLines =0;
    //建立5个button
    UIButton *btn5 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btn5 setTag:100+Row*5];
    btn5.frame = CGRectMake(120.0f, 0.0f, 30.0f, 40.0f);
    [btn5 setTitle:@"" forState:UIControlStateNormal];
    UIImage * buttonImageNormal=[UIImage imageNamed:@"5.jpg"];
    [btn5 setBackgroundImage:buttonImageNormal forState:UIControlStateNormal];
   [btn5 addTarget:self action:@selector(asender:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *btn4 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btn4 setTag:100+Row*5+1];
     btn4.frame = CGRectMake(160.0f, 0.0f, 30.0f, 40.0f);
    [btn4 setTitle:@"4" forState:UIControlStateNormal];
    [btn4 addTarget:self action:@selector(asender:) forControlEvents:UIControlEventTouchUpInside];
        UIButton *btn3 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btn3 setTag:100+Row*5+2];
    
    btn3.frame = CGRectMake(200.0f, 0.0f, 30.0f, 40.0f);
    [btn3 setTitle:@"3" forState:UIControlStateNormal];
    [btn3 addTarget:self action:@selector(asender:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btn2 setTag:100+Row*5+3];
    btn2.frame = CGRectMake(240.0f, 0.0f, 30.0f, 40.0f);
    [btn2 setTitle:@"2" forState:UIControlStateNormal];
    [btn2 addTarget:self action:@selector(asender:) forControlEvents:UIControlEventTouchUpInside];
    
    
    UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btn1 setTag:100+Row*5+4];
    btn1.frame = CGRectMake(270.0f, 0.0f, 30.0f, 40.0f);
    [btn1 setTitle:@"1" forState:UIControlStateNormal];
    [btn1 addTarget:self action:@selector(asender:) forControlEvents:UIControlEventTouchUpInside];
    //B1GetArray从aview传过来的数组。和每一个button tag 对比。进行隐藏按钮
    for (int i;i<[B1GetArray count];i++) {
        int tagB1 = [[B1GetArray objectAtIndex:i] intValue];
     NSLog(@"%i",btn1.tag);
        if (btn1.tag==tagB1){
  btn1.hidden=YES;
    
        }
        else{
             btn1.hidden=NO;
        }
btn1输出的永远是一个数值,是我的逻辑有问题么?如果我把btn1 放在for循环下面 我所有的tag都回读出来。但是在for里面就只会读一个。