代码部分,
(void)scorView:(NSArray *)arr;
{
for (int i = 0; i < arr.count; i++) {
_scorview = [[UIView alloc] initWithFrame:CGRectMake(i * 375, 0, 375, 667 - 64 - 57 - 45)];
_scorview.backgroundColor = [UIColor blueColor];
_scorView.tag = 1000+i;
[self.myFootS addSubview:_scorview];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(120, 60, 135, 40)];
label.text = arr[i];
label.textColor = [UIColor redColor];
[_scorview addSubview:label];
UICollectionViewFlowLayout * layout = [[UICollectionViewFlowLayout alloc] init];
layout.itemSize = CGSizeMake(339/2*SCALE_VALUE, 490/2*SCALE_VALUE);
_collection = [[UICollectionView alloc] initWithFrame:CGRectMake(0,0, self.view.width, 510) collectionViewLayout:layout];
_collection.backgroundColor = [UIColor whiteColor];
_collection.delegate = self;
_collection.dataSource = self;
[_collection registerClass:[MallCell class] forCellWithReuseIdentifier:@"mall"];
// [_collection registerClass:[HeadCollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:[NSString stringWithFormat:@"headMall%d", i]];
[_scorview addSubview:_collection];
}
}
怎么对应的传值
麻烦一点的话可以获取坐标来定位是那个view。
还有可以用 .tag = i ;设定每个view的标示。比如for ( int i = 0; i < arr.count ; i++ ){button = i+66;}把设置标识放在for循环里。
用的时候switch (button.tag) {
case 66:
break;
case 67:
break;
case 68:
break;
case 69:
break;
。。。。。。
设置tag标记。通过tag值对应传值。