I'm having a problem trying to programmatically resize the height of a UITableView
hosted within a UIViewController
, using iOS5 and Storyboards. The VC displays a master/detail record style with the UITableView
displaying the detail records. Depending on the type of master record shown, a set of buttons may be needed at the foot of the screen. If the buttons are not needed then I want the UITableView
to extend it's height to take advantage of the space available. I'm using the following code :
CGRect tableFrame = [tableListView frame];
if (blnApprovalRec == YES)
tableFrame.size.height = 127;
else
tableFrame.size.height = 170;
[tableListView setFrame:tableFrame];
This code is called whenever the master record changes, including when the screen first loads in viewDidLoad
. The problem is that when the VC loads, the UITableView
doesn't paint using the size specified - it just paints with the default size from IB. Once the user changes the master record so the table is reloaded then everything works fine and the size changes as required. I've tried forcing a repaint using setNeedsDisplay
, setNeedsLayout
and reloadData
but none of these worked.