May I know is what are the solution to use in order to make the following code working in order.
- (CGFloat)getRowImageHeight
{
CGFloat defaultHeight =
Things that I am trying to do is at view load, I preload the image before it appears on the view. Then get image block to return the image height and I wanted to return back the height to
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
But it seems that answers above told me that the approach is impossible. So I tried to use delegate and return the height to main view and update the cell height by using the code below after the image has been successfully fetch at cell level.
- (void)reloadItemImageTVCellHeight:(CGFloat)height
{
if( !self.hasUpdatedImageCellHeight ){
self.hasUpdatedImageCellHeight = YES;
self.itemImageCellHeight = height;
[self.mTableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:ROW_IMAGE inSection:0]]
withRowAnimation:UITableViewRowAnimationNone];
}
}
In viewDidLoad, I've set self.hasUpdatedImageCellHeight to NO and self.itemImageCellHeight to 300.f. self.hasUpdatedImageCellHeight is to control whether the delegate has already return me any value, if YES then I will update it to YES in order to prevent the delegate codes keep calling again & again.
This is my approach for it, but still it is best if there is an approach that can know the image height natively before the table view being completely loaded.