我有一个 UITableViewController,我需要垂直调整表格的大小。
我不能使用带有表的 UIViewController。
有方法吗?
谢谢!
我有一个 UITableViewController,我需要垂直调整表格的大小。
我不能使用带有表的 UIViewController。
有方法吗?
谢谢!
这只有在您的UITableViewController
视图被手动添加到另一个超级视图时才有可能。但是,如果您计划在导航控制器中使用表格视图或作为模式表,您无法控制表格视图的大小。
要完全控制表视图大小:
UIViewController
使用UITableView
插座和资源文件让您拥有自己的子类。view
并相应地调整它的大小。UITableViewDataSource
和UITableViewDelegate
协议。而不是使用 a ,使用带有属性UITableViewController
的标准可能更容易。UIViewController
UITableView
例如:
@interface ContentsPopover : UIViewController <UITableViewDelegate, UITableViewDataSource>
//...
@property (nonatomic, strong) UITableView *theTableView;
//...
@end
这样,UIViewController
您可以在您的内部拥有以下代码(可能在 viewDidLoad 中):
theTableView = [[UITableView alloc] initWithFrame:/*...*/ style:UITableViewStylePlain];
theTableView.delegate = self;
theTableView.dataSource = self;
theTableView.scrollEnabled = YES;
[self.view addSubview:theTableView];
// You can now change theTableView's frame property as needed
当 aUITableViewController
不是您要查找的内容时,这很方便。