Reputation: 13947
I have a table view which has dynamic cells created by code. In IOS 7
to make sure the cell is displayed fully, I override the method heightForRowAtIndexPath
overriding this method in ios8 seems to make my cells just be one on top of the other, and all sized 67.0003
I do not want to create an autolayout layout for the cells, they are too complex and already made
Is there a way to fix the height issue in ios 8?
Upvotes: 3
Views: 7192
Reputation: 952
UITableViewAutomaticDimension is only working with autolayout. If you don't use autolayout, don't use something like
self.tableView.rowHeight = UITableViewAutomaticDimension;
It would be helpful if you could provide your controller's code.
Upvotes: 3
Reputation: 39
If you want dynamic cell hight you need to set size of cell first
For example: you want to give some text info in every tableview cell first you need to calculate the height of cell according to the and then set the height of cell in heightForRowAtIndexPath
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath: (NSIndexPath *)indexPath
{
NSString* text= [yourArray objectAtIndex:indexPath.row];
CGSize textSize= [text getTextSize];
if (textSize<SomeMinValue)
{
textSize= CGSizeMake(cellWidth, SomeMinValue)
}
return textSize.height;
}
Upvotes: 0
Reputation: 13947
There is no problem with the method heightForRowAtIndexPath, it works well in ios8 as well The problem was in my heightForRowAtIndexPath i wrote
CGSize size;
a bunch of ifs
size.height = something
and in other cases i had
size.height+= something
and size.height
was not always 0 at start
Upvotes: 3