初学者:如何在 UITableViewController 上添加带有按钮的顶部栏

发布于 2025-01-08 01:59:30 字数 168 浏览 4 评论 0原文

我是 iOS 开发新手,故事板中只有 UITableViewController 。我想添加一个带有一些按钮的顶部栏,该怎么做?

请注意,我使用的是由“Storyboard”创建的 UITabBar,而我的 ITableViewController 是 UITabBar 的一项。

I'm new to iOS development, I just have UITableViewController in a storyboard. I would like to add a top bar to it with some buttons, how to do that?

Notice, I'm using UITabBar that is created by "Storyboard" and my ITableViewController is one item of the UITabBar.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

绝情姑娘 2025-01-15 01:59:30

创建 UITableViewController 时,请执行以下操作:

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:tableViewController];

然后不要将表视图控制器设置为视图,而是将其设置为导航控制器。在表视图控制器内,您可以将导航栏的左右按钮设置为 UIBarButtonItem(如果您想知道如何执行此操作,请询问我)。

When you create the UITableViewController, do the following:

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:tableViewController];

and then instead of setting the table view controller as the view, set it to the navigation controller. Inside your table view controller, you can set the left and right buttons for the navigation bar to UIBarButtonItems (ask me if you want to know how to do that).

執念 2025-01-15 01:59:30

选择您的 UITableViewController 并转到 Editor >嵌入并选择导航控制器。

Select your UITableViewController and go Editor > Embed In and choose a navigation controller.

北方的巷 2025-01-15 01:59:30

您可能会考虑使用 UINavigationController。
https://developer.apple.com/library /ios/DOCUMENTATION/UIKit/Reference/UINavigationController_Class/Reference/Reference.html

如果你不想使用 UINavigationController,那么你可以可以做的是创建一个具有您正在寻找的“顶栏”的视图,然后将 UITableViewController 的视图添加到您的新 UIView 中。

You might look at using the UINavigationController.
https://developer.apple.com/library/ios/DOCUMENTATION/UIKit/Reference/UINavigationController_Class/Reference/Reference.html

If you do not want to use UINavigationController, then what you could do is create a view that has the "top bar" that you are looking for, then add the UITableViewController's view to your new UIView.

北城孤痞 2025-01-15 01:59:30

您需要创建一个 UIViewController,而不是 UITableViewController,然后根据需要放置所需的元素(在本例中为表视图和 UIToolbar)。

You need to create an UIViewController, not a UITableViewController, and then place the elements you desire however you want (in this case, a Table View and a UIToolbar).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文