0
Вот мой кодДобавить UILabel к определенному indexpath в UICollectionView
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return 10;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
CollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"dfdsfs" forIndexPath:indexPath];
if (indexPath.item == 0) {
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 100, 50)];
label.text=[NSString stringWithFormat:@"this is item %ld", (long)indexPath.item];
[cell.contentView addSubview:label];
cell.contentView.backgroundColor = [UIColor greenColor];
NSLog(@"im @ zero");
} else {
NSLog(@"im here %ld", (long)indexPath.item);
cell.contentView.backgroundColor = [UIColor yellowColor];
}
return cell;
}
Я хочу, чтобы ярлык будет добавлен в пути индекса только ноль. Я получаю вопрос, как метка появляется в других путях индекса также ..
ответ –
@SunilKumar Добро пожаловать! Это сработало? Если да - примите мой ответ. – ppalancica