简体   繁体   English

如何在视图中更改UITableView的位置?

[英]How to change the position of an UITableView in a View?

I have a view where I push a button and this code is loaded: 我有一个按下按钮的视图,并且此代码已加载:

    TestView *testView = [[TestView alloc] initWithNibName:@"TestView" bundle:nil];        
    [testView.table setFrame:CGRectMake(0, 200, 320, 188)];        

    testView.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [(UIViewController*) currentOb presentModalViewController:testview animated:YES];

The nib of TestView, where I have a table, is loaded fine, but the table is still in the position (0,0) intead of (0,200). 我有一个表的TestView的笔尖加载得很好,但表仍位于(0,0)中间(0,200)的位置。 Do u know what I am doing wrong? 你知道我做错了吗?

Thanks and sorry my bad english. 谢谢,对不起我的英语不好。

我找到了,这可能是解决此问题的最佳方法:

[self.tableView setContentInset:UIEdgeInsetsMake(50,0,0,0)];

尝试

testview.table.frame = CGRectMake(0,200,320,188);

Did you connect the table outlet of TestView to the table in Interface Builder? 您是否将TestView的表出口连接到Interface Builder中的表? It's easy to forget, in which case something like this would happen. 很容易忘记,在这种情况下会发生这种情况。

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

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