在UITableViewCell里面,我们可以通过viewWithTag方法来访问Subview,这是一种快速但是比较邋遢的方式。这种方法的好处是可以快速的访问一堆连号的控件(subview),而不需要一个个的通过Ctrl drag来设置IBOutlet。下面是根据NSMutableArray设置UI的代码,好用。

int i = 0;

    for(id number in draw.primaryNumbers){

        UILabel *n = (UILabel *)[cell viewWithTag:300+i];

        // NSLog(@"%@", n);

        n.text = number;

        

        NSString* imageFile = [NSString stringWithFormat:@"Images/ball.png"];

        UIImageView * imageBall = (UIImageView *)[cell viewWithTag:200 + i];

        imageBall.image = [UIImage imageNamed:imageFile];

        ++i;

    }

相关文章:

  • 2021-12-21
  • 2021-09-08
  • 2022-12-23
  • 2021-06-17
  • 2021-08-04
  • 2021-12-05
  • 2021-05-18
  • 2021-06-08
猜你喜欢
  • 2022-01-16
  • 2022-01-06
  • 2022-12-23
  • 2021-12-16
  • 2021-06-03
  • 2021-09-04
相关资源
相似解决方案