ios - 设置 UITableView 的高度

标签 ios uitableview height

出于某种原因,我无法从我的 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/

相关文章:

ios - 如何重新加载整个 UIViewController 页面

iphone - UITableViewCell AutoRelease 导致崩溃...?

iphone - 如何获得 UITableView 的可见矩形?

jquery - 设置侧边栏的高度以匹配容器

ios - 将 integerForKey 与字符串 swift 一起使用

ios - NSDateFormatter 区别

android - Xamarin.Forms - ControlTemplate 不显示 ContentPresenter

objective-c - UITableView:显示 tableFooterView 时运行代码?

html - 如何用css设置高度和下一节课一样

html - 百分比高度与最小高度的行为是什么?