如何在 Interface Builder 中设置 UITableView 的大小?
是否可以在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您在 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 :)
您可以在 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:
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
onviewDidAppear
.