Я хочу, чтобы изменить размер моего UICollectionViewCellНеправильный UICollectionViewCell размер
В Interface Builder я установить пользовательский размер
В моем коде я хочу изменение размера ячейки
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return CGSizeMake(274, 274);
}
В будущем мне понадобится разный размер ячейки
В моей камере у меня есть следующий метод
- (void)awakeFromNib
{
backImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height/1.32)];
[self addSubview:backImageView];
lineImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, backImageView.height, self.width, self.height/9.67)];
[self addSubview:lineImageView];
nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(28, lineImageView.originY + 5, self.width - 28, 15)];
nameLabel.font = [UIFont fontWithName:FontStyleBold size:14];
[self addSubview:nameLabel];
descriptLabel = [[UILabel alloc] initWithFrame:CGRectMake(nameLabel.originX, lineImageView.originY + lineImageView.height + 3, nameLabel.width - nameLabel.originX, 25)];
descriptLabel.numberOfLines = 2;
descriptLabel.font = [UIFont fontWithName:FontStyle size:8];
[self addSubview:descriptLabel];
self.backgroundColor = [UIColor whiteColor];
self.layer.masksToBounds = NO;
self.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(-1, 2.0, self.width + 2, self.height + 2) cornerRadius:0.f].CGPath;
self.layer.shadowColor = [[UIColor blackColor] CGColor];
self.layer.shadowOpacity = .4f;
self.layer.shadowRadius = 2.0f;
}
В тренажере у меня есть следующий плохой результат
Если установить в размере Interface Builder
В тренажере все хорошо
Я думал, что следующий метод должен изменить размер ячейки, но изменить размер элемента
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return CGSizeMake(274, 274);
}
Так как я могу изменить размер UICollectionViewCell программно, без помощи Interface Builder?
Если вы удалите значения в IB обычно помогает :) – Fogmeister
Если удалить, IB автоматически устанавливается 0,0 и задачи оставайтесь – MaximusAlarmus