UITableView less than full screen from code?
I have a number of views that use UITableView. (I use UIViewController and implement UITableViewDelegate and UITableViewDataSource interfaces.) I'm having trouble creating a tableview that leaves room at the top for a toolbar. How to I size and layout the Tableview so that it is less than full screen? Is this an AutoResizing mask problem?
Th开发者_C百科anks, Gerry
You need to modify the table view frame to size for the toolbar. For example, you would run something like the following:
CGRect tableFrame;
tableFrame.origin.x = 0;
tableFrame.origin.y = toolbarReference.frame.size.height;
tableFrame.size.width = self.view.frame.size.width;
tableFrame.size.height = self.view.frame.size.height - toolbarReference.frame.size.height;
tableviewReference.frame = tableFrame;
This calculates the coordinates and size minus the toolbar at the top and then sets the frame of the tableview to those coordinates.
精彩评论