如何在 Interface Builder 中设置 UITableView 的大小?

发布于 2024-12-29 15:48:00 字数 98 浏览 3 评论 0原文

是否可以在 Interface Builder 中更改 UITableViewController 的 UITableView 框架的框架?我想让我在 IB 中实例化的表稍微窄一点。

Is it possible to change the frame of UITableViewController's UITableView frame inside Interface Builder? I want to make my table, which I instantiate in IB, a little bit narrower.

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

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

发布评论

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

评论(2

哭泣的笑容 2025-01-05 15:48:00

当您在 IB 中创建 tableViewController 后,如果您转到屏幕右侧的部分,其中所有选项的大小都设置为“自由格式”,然后将其拖动到您喜欢的任何位置。当你初始化它时,它就会得到这个框架。除非它在容器控制器内。

执行此操作的最佳方法是创建一个 viewController 并将表视图添加到其视图中。使表格视图比主控制器视图更窄,并将其连接到控制器上的 IBOutlet。如果你让你的控制器实现 和 方法,你将能够完全按照你想要的方式使用你的表视图。

希望这对您有所帮助,如果不清楚或您需要任何额外帮助,请告诉我:)

When you have create your tableViewController in IB, if you then go to the section on the right of the screen where all the options are set size to "freeform" then drag it to whatever you like. When you init it it will then get this frame. Unless it is within a container controller.

The best way to do what you are after is to create a viewController and add a table view to its view. Make the table view narrower that the main controller view and wire it up to an IBOutlet on your controller. If you then make your controller implement the and methods you will be able to use your table view exactly as you want to.

Hope this is of help to you, if this is unclear or you would like any extra help, let me know :)

征﹌骨岁月お 2025-01-05 15:48:00

您可以在 IB 中更改它,但除非您以某种方式自定义视图控制器,否则它会将其设置为全屏(包含导航、选项卡栏、分割视图等控制器的模块),这就是视图控制器的工作方式。

来自苹果文档:

当视图控制器显示在屏幕上时,它的根视图是
通常会调整大小以适应可用空间,这可能会有所不同
窗口的当前方向和其他窗口的存在
界面元素,例如状态栏。

您可以创建另一个 UIView 来保存您的表视图,然后对表视图的大小进行更多控制,但是这样您就不会成为表视图控制器,并且必须实现表视图的一些内容视图控制器为您提供,例如,viewDidAppear 上的deselectRowAtIndexPath

You can change it in IB but unless you customize your view controller somehow, it will set it be full screen (module enclosing controllers like nav, tab bar, split view, etc.) That's just the way view controllers work.

From the Apple docs:

When a view controller is displayed on screen, its root view is
typically resized to fit the available space, which can vary depending
on the window’s current orientation and the presence of other
interface elements such as the status bar.

You can create another UIView to hold your table view and then have more control over the table view sizing, But then you won't be a table view controller and will have to implement some of the things that table view controller provides you, e.g., deselectRowAtIndexPath on viewDidAppear.

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