UITableView不到全屏代码? [英] UITableView less than full screen from code?
问题描述
我有很多使用UITableView的视图。 (我使用UIViewController并实现UITableViewDelegate和UITableViewDataSource接口。)我在创建一个tableview时遇到了麻烦,这个工作区顶部留有空间。如何调整Tableview的大小和布局,使其低于全屏?这是一个AutoResizing掩码问题吗?
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?
谢谢,
格里
推荐答案
您需要将表视图框修改为工具栏的大小。例如,您将运行如下内容:
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;
这会计算坐标和大小减去顶部工具栏,然后将tableview的框架设置为那些坐标。
This calculates the coordinates and size minus the toolbar at the top and then sets the frame of the tableview to those coordinates.
这篇关于UITableView不到全屏代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!