У меня есть UILabel
в заголовке collectionView
. Метка устанавливается на нулевые строки, перенос слов и правильные ограничения ведущего/конечного/верхнего пространства. Если я НЕ звоню [collectionView reloadData]
, ярлык правильно расширяется до текста с более чем двумя строками. Когда вызывается reloadData
, метка возвращается к одной строке ... вторая строка исчезает.UICollectionView `reloadData` приводит к исчезновению строк UILabel
- (UICollectionReusableView *) collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
if (kind == UICollectionElementKindSectionHeader) {
header = (viewRollHeader *) [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header" forIndexPath:indexPath];
header.rollTitle.text = [self.roll objectForKey:@"title"];
header.rollDescription.text = [self.roll objectForKey:@"info"];
[header.cancelButton addTarget:self action:@selector(exit) forControlEvents:UIControlEventTouchUpInside];
return header;
}
return [UICollectionReusableView new];
}
- (CGSize) collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
if (section == 0) {
CGRect labelRect = [[self.roll objectForKey:@"title"]
boundingRectWithSize: header.rollTitle.frame.size
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName : [UIFont fontWithName:@"Arial-BoldMT" size:32.0f]}
context:nil];
return CGSizeMake([[UIScreen mainScreen]bounds].size.width, (174.0f + labelRect.size.height));
}
return CGSizeZero;
}
сообщение код пожалуйста. – Ismail
@ Ismail это делается в раскадровке. Только код reloadData – Peter
как вы можете обрабатывать все для 'UICollectionView' в раскадровке ??? Где методы dataSource/delegate? – Ismail