Мне нужно установить высоту для ячеек на основе высоты UIImageView, которая scaledHeight
переменной им получать изображения с Parse, как это в моем cellForRowAtIndexPathКак установить разные высоты UITableViewCell на основе высоты UIImageView?
PFFile *userImageFile = object[@"image"];
[userImageFile getDataInBackgroundWithBlock:^(NSData * _Nullable data, NSError * _Nullable error) {
if (!error) {
// UIImageView *imageView = (UIImageView *)[cell viewWithTag:1];
UIImage *image = [UIImage imageWithData:data];
// imageView.image = image;
UIImageView *test = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 400, 320)];
test.image = image;
CGSize imgSize = image.size;
CGFloat ratio = test.frame.size.width/imgSize.width;
CGFloat scaledHeight = imgSize.height * ratio;
[test setFrame:CGRectMake(0, 0, self.view.window.frame.size.width, scaledHeight)];
NSLog(@"HEIGHT:%f",scaledHeight);
[cell addSubview:test];
}
} progressBlock:^(int percentDone)
{
}];
как я могу установить scaledHeight
внутри heightForRowAtIndexPath
в heightForRowAtIndexPath
является запустить до CellForRowAtIndexPath
?
как бы вычислить высоту изображения внутри 'heightForRow..' – farhan
imageView.size.height даст вам высоту. –
Как бы это сделать, если изображениеView установлено в cellForRow? – farhan