gpt4 book ai didi

ios - 在不使用 NavigationController 的情况下将导航栏添加到 UITableViewController

转载 作者:行者123 更新时间:2023-12-01 22:46:32 24 4
gpt4 key购买 nike

我正在尝试将导航栏添加到 UITableViewController 没有 使用 NavigationController .

所以在 viewDidLoadMethodMyUITableViewController ,我创建一个Navigation Bar使用 CGRect。

UINavigationBar * navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 30, 320, 50)];

然后我从 MainViewController 呈现 MyUITableViewController
   [self presentViewController:controller animated:YES completion:Nil];

此时我的 MyUITableViewControllerNavBar 重叠

我正在考虑使用 initWithFram(x, y, width, height) 创建 tableViewController 来补偿 NavBar。

但我不确定我应该使用什么高度以及如何得出一个值。 它会有正确的滚动行为吗?

什么是正确的方法?请注意此时我不想使用导航 Controller 。

是否有可能没有导航 Controller 。

最佳答案

尽量不要使用 UITableViewController,而是简单的使用 UIViewController,在上面添加一个 UITableView 对象,同时实现表格 View 的 2 个协议(protocol)。

您可以根据需要调整表格 View 的大小,如果您还需要显示状态栏,可以将其原点 Y 坐标设置为 44 或 64。

你可以在它上面添加一个 UINavigationBar 对象。

我希望这样做可以帮助您解决问题。

关于ios - 在不使用 NavigationController 的情况下将导航栏添加到 UITableViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25322847/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com