简体   繁体   English

如何在 UIView 中将 UITableView 居中

[英]How to center a UITableView in a UIView

My table has about 5 items.我的桌子有大约 5 个项目。 The table, which is created through IB, appears at the top of view.. How would I center the UItableView such that it appears lower (example: http://i.stack.imgur.com/G9QoS.png )通过 IB 创建的表格出现在视图的顶部。我如何将 UItableView 居中以使其显得更低(例如: http://i.stack.imgur.com/G9QoS.png

Thanks谢谢

Edit: Answer is to modify the frame and assign it a CGRect in viewDidAppear method编辑:答案是修改框架并在 viewDidAppear 方法中为其分配一个 CGRect

self.menuitems.frame=CGRectMake(self.menuitems.frame.origin.x,200.0,self.menuitems.frame.size.width,self.menuitems.frame.size.height);

Thanks to AAAAAAAAA and slev感谢 AAAAAAAAA 和 slev

For better way you can directly modify the frame of the tableView.为了更好的方式,您可以直接修改 tableView 的框架。 like喜欢

tableView.frame=CGRectMake(your frame dimensions what ever you want );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM