如何设置3个UITable和2个导航栏的位置?
我的 XIB 有 3 个 UITable 和 3 个导航栏。UITable 是动态缩放的,我使用导航栏来分隔 UITable 并显示 UITable 名称的标题。
我想在第一个表格下设置第一个导航栏,在第二个表格下设置第二个导航栏。
我尝试找到第一个桌子的框架来获取位置 x,y 和桌子的高度,但它不起作用。
- (void)viewDidLoad
{
blah blah...
CGRect table1frame = table1.frame; //But it don't work
}
我不知道从哪里得到每个桌子框架。 请帮助我或指导我。非常感谢
My XIB has 3 UITable and 3 Navigation bar.UITables are dynamic scale and I use navigation bar to seperate UITable and show title of UITable name.
I want to set first navigation bar under the first table and second navigation bar under second table.
I try to find frame of first table to get position x,y and height of table but it don't work.
- (void)viewDidLoad
{
blah blah...
CGRect table1frame = table1.frame; //But it don't work
}
I don't know where to get each table frame.
please help me or guide me.Thank you very much
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定我是否理解您要执行的操作,但请记住,当调用
viewDidLoad
时,视图控制器视图的几何形状(其边界)尚未设置。任何子视图的边界(和框架)也尚未设置。这意味着此时所有帧几乎都设置为零。而且,如果您尝试访问视图的框架或其任何子视图的框架,这可能就是您所注意到的,因此,如果您需要基于视图的几何形状(在其框架或任何子视图的框架上)执行任何操作 ,其子视图),通常在
viewWillAppear
中完成。您的问题可能不是在哪里获取表格视图的框架,而是何时获取它。您正在正确的位置(表视图的框架属性)寻找它,但您还为时过早。我希望这有帮助。
I'm not sure I understand what you're trying to do, but keep in mind that the geometry of the view controller's view (its bounds) is not yet set when
viewDidLoad
is called. The bounds (and frames) of any subviews have not been set either. That means that all frames are pretty much set to zero at this point. And, that may be what you are noticing if you are trying to access the view's frame, or the frame of any of its subviews,So, if you need to do anything based on the view's geometry (on its frame or the frame of any of its subviews), it is generally done in
viewWillAppear
.Your problem may not be where to get the table view's frame, but when to get it. You are looking for it in the right place (the table view's frame property), but you are too early. I hope this is helpful.