Как отобразить изображение с помощью PureLayout в пользовательском UITableViewCell?

Я создаю приложение для опроса изображений на iOS. Фид будет экземплярами записи, похожей на опубликованное изображение (без границ). Я создал кастом UITableViewCell используя PureLayout. Тем не менее, изображение (которое загружается асинхронно) не отображается.

введите описание изображения здесь

Я пробовал такие вещи, как invalidateIntrinsicContentSize в обработчике завершения изображения, но не работает. Я новичок в AutoLayout и следую этому примеру кода

Вот мои настройки ограничения для изображения и 2 верхних меток

- (void) updateConstraints {
    if (!self.didSetupConstraints) {

        self.contentView.bounds = CGRectMake(0.0f, 0.0f, 99999.0f, 99999.0f);

        [NSLayoutConstraint autoSetPriority:UILayoutPriorityRequired forConstraints:^{
            [self.questionLabel autoSetContentCompressionResistancePriorityForAxis:ALAxisVertical];
        }];
        [self.questionLabel autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:kLabelVerticalInsets];
        [self.questionLabel autoPinEdgeToSuperviewEdge:ALEdgeLeading withInset:kLabelHorizontalInsets];
        [self.questionLabel autoPinEdgeToSuperviewEdge:ALEdgeTrailing withInset:kLabelHorizontalInsets];


        [self.nameLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.questionLabel withOffset:kLabelVerticalInsets];

        [NSLayoutConstraint autoSetPriority:UILayoutPriorityRequired forConstraints:^{
            [self.nameLabel autoSetContentCompressionResistancePriorityForAxis:ALAxisVertical];
        }];
        [self.nameLabel autoPinEdgeToSuperviewEdge:ALEdgeLeading withInset:kLabelHorizontalInsets];
        [self.nameLabel autoPinEdgeToSuperviewEdge:ALEdgeTrailing withInset:kLabelHorizontalInsets];
        [self.nameLabel autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:kLabelVerticalInsets];



        [NSLayoutConstraint autoSetPriority:UILayoutPriorityRequired forConstraints:^{
            [self.mainImageView autoSetContentCompressionResistancePriorityForAxis:ALAxisVertical];
        }];

        [self.mainImageView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.nameLabel withOffset:kLabelVerticalInsets];

        [self.mainImageView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:0];
        [self.mainImageView autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:0];
        [self.mainImageView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:0];


        self.didSetupConstraints = YES;
    }

    [super updateConstraints];
} 

0 ответов

Другие вопросы по тегам