出于某种原因,我无法从我的 Controller 中调整 UITableView 的高度,在我的 viewDidLoad 中,我这样做了:
[self.tableView setBounds:CGRectMake(0.0f, 0.0f, 320.0f, 100.0f)];
[self.tableView setFrame:CGRectMake(0.0f, 0.0f, 320.0f, 100.0f)];
self.tableView.bounds = CGRectMake(0.0f, 0.0f, 320.0f, 100.0f);
self.tableView.frame = CGRectMake(0.0f, 0.0f, 320.0f, 100.0f);
我刚刚尝试了所有选项,但似乎没有任何改变我的 table 的高度。
最佳答案
UITableViewController 会自动让 tableview 全屏。
取自View Controller Programming Guide :
Note: You should use a UIViewController subclass rather than a subclass of UITableViewController to manage a table view if the view to be managed is composed of multiple subviews, one of which is a table view. The default behavior of the UITableViewController class is to make the table view fill the screen between the navigation bar and the tab bar (if either are present).
关于ios - 设置 UITableView 的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10748384/