简体   繁体   中英

How to position a UITableView correctly at a fixed point from the top of the view

I'm trying to position a UITableView 200 points from the top of the view. I'm able to do that with the following code. The problem I have is that half of the last row doesn't scroll and is obscured/hidden.

How can I change this line self.mainTableView.frame = CGRectMake(0,200,320,600); so that the table ends at the bottom of the view correctly and is sized so that all rows scroll fully within the view.

thanks for any help

self.mainTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
self.mainTableView.frame = CGRectMake(0,200,320,600);
self.mainTableView.autoresizingMask = ( UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth );
self.mainTableView.dataSource = self;
self.mainTableView.delegate = self;

编写以下代码,可能会对您有帮助:

self.mainTableView.frame = CGRectMake(0,200,320,self.view.frame.size.height-200);

这样做可以使桌子触摸屏幕的末端:

self.mainTableView.frame = CGRectMake(0, self.view.bounds.size.height - 600, 320, 600);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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