Can someone summarise the key pieces of objective-c code that would assist in solving this.
Objective – Autoresize a UITableView after a user changes the font size. Therefore if the user increases or descreases font both the (a) uiLabel heights should change to ensure they nicely include text, and (b) uiTableViewCell heights should also adjust.
Assumption is that:
- UITableView has been extended via
creation of a custom cell view –
i.e. create a new view in a NIB that
forms for the content view of the
UITableView cells - each custom
cell has four UILabel’s which form a
2 x 2 patter of UILabels – i.e. two
on top line and two on bottom line - so as the user increases the font
the horizontal spacing of the
UILabels would remain the same,
however the label heights would
change
So I assume the challenge / questions I have would include (and hopefully be answered by some sample code that someone can post)
- Is it OK that the starting point here is an already laid out custom UITableViewCell in InterfaceBuilder? (or does the solution require it is constructed totally programmatically)?
- How to calculate the heights the label’s should be? Is this just with the NSString method “sizeWithFont:minFontSize:actualFontSize:forWidth:lineBreakMode:”, and do I need to add addition for margins etc?
- How programmatically to increase the height of the labels dynamically – in which method do you do this & how to change the height itself
- How to ensure that when UILabel at the top is expanded & grows, that it automatically pushes down the UILabel on the 2nd row? Does this happen by default or is there a specific property/setting you have to you to ensure this hapens.
- How to then automatically increase the height of the TableViewcell, after the above has occurred. Which method to do this in, and how programmatically to perform the increase & redraw.
Hope this makes sense.
thanks
1 Answer