使用 Interface Builder 将 UITableView 放在导航栏下方
Place UITableView below Navigation bar with Interface Builder
我正在开发具有以下场景的情节提要:导航控制器具有 UITableViewController(父亲)。 Father 中有一个单元格执行 segue,打开一个新的 UIViewController:Son。在 Son 中,我拖了一个 UITableView 和一个 Navigation Item,因为我想在导航栏中有一个刷新按钮。
但是,当我 运行 项目时, table 不适合导航栏下方。此外,它在视图的页脚中似乎是一个空的 space。我应该在界面生成器中设置或修改什么属性,才能让 table 在导航栏之后开始,并填充整个视图?
您无需手动将导航拖动到 "son" 控制器。只需将 segue 的类型指定为 "show",您的 "son" 控制器应该从父控制器继承导航栏。
关于刷新按钮,您可以在代码中创建一个并将其添加到导航栏中,例如:
self.refreshButton=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(resetButtonTapped:)];
self.navigationItem.rightBarButtonItem=self.refreshButton
解决方案非常简单,只需要包含以下行:
self.navigationController.navigationBar.translucent = NO;
我正在开发具有以下场景的情节提要:导航控制器具有 UITableViewController(父亲)。 Father 中有一个单元格执行 segue,打开一个新的 UIViewController:Son。在 Son 中,我拖了一个 UITableView 和一个 Navigation Item,因为我想在导航栏中有一个刷新按钮。
但是,当我 运行 项目时, table 不适合导航栏下方。此外,它在视图的页脚中似乎是一个空的 space。我应该在界面生成器中设置或修改什么属性,才能让 table 在导航栏之后开始,并填充整个视图?
您无需手动将导航拖动到 "son" 控制器。只需将 segue 的类型指定为 "show",您的 "son" 控制器应该从父控制器继承导航栏。
关于刷新按钮,您可以在代码中创建一个并将其添加到导航栏中,例如:
self.refreshButton=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(resetButtonTapped:)]; self.navigationItem.rightBarButtonItem=self.refreshButton
解决方案非常简单,只需要包含以下行:
self.navigationController.navigationBar.translucent = NO;