I am doing UITableview cell height (Dynamic height) as per UIImageView height, currently it's working fine but my problem is UITableview is not smoothly scrolling or not working properly if i scroll fastly
I think problem is i am reloading the row in tableview cell so tableview scroll is not working can anyone tell me any good suggestion for this problem ?
Here what i did
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// Create the cell...
[cell.myImageView setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"]
placeholderImage:[UIImage imageNamed:@"placeholder"]
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
if (image != nil) {
[self.images insertObject:image atIndex:indexPath.row];
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:YES];
}
}];
return cell;
}
For setting height as per Image
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
id image = [self.images objectAtIndex:indexPath.row];
if ([image isKindOfClass:[NSNull class]]) {
return defaultHeight;
} else {
return [image size].height + topPadding + bottomPadding;
}
}