开发者

UITableView less than full screen from code?

开发者 https://www.devze.com 2022-12-31 19:45 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消