Two UITableViewCell related questions:
- In my custom UITableViewCell I loop through an array (of which I do not know how many objects it holds) and add a UILabel displaying some text for each object in that array.
This means I have to adjust the height of the cell so that these labels fit in. How can I do this?
- When going into edit mode, I have the cells indent, however I do not want this. I have tried the following:
cell.shouldIndentWhileEditing = NO;
and
-(BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
return NO;
}
Both sadly failed, I have I no idea why. How could I remedy this?
You can specify the height for every row with the delegate method
[UITableViewDelegate tableView:heightForRowAtIndexPath:].Just change what the method returns and the reload your table.
This method actually has nothing to do with the indendation of cell content:
You can try to set
indentationWidthbut I never managed to make it work.Fortunately, it’s easy to change everything you want in
[UITableView layoutSubviews]method.Example:
- (void)layoutSubviews { [super layoutSubviews]; self.contentView.frame = self.bounds; }