Position a UIView at the middle of a UITableView with CGRectZero frame

Posted by Thomas Joulin on Stack Overflow See other posts from Stack Overflow or by Thomas Joulin
Published on 2010-04-02T10:18:56Z Indexed on 2010/04/02 10:23 UTC
Read the original article Hit count: 368

Filed under:
|
|
|

Hi,

I have a UITableViewController view a UITableView that I alloc/init with a frame of CGRectZero :

self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];

I want to add a view at the middle of the tableView (a loading view with a UIActivityIndicatorView and a UILabel), but I don't know how to position it, since I don't know the tableView frame.

x = (self.tableview.frame.size.width - loadingView.frame.size.width) / 2.0;
y = (self.tableview.frame.size.height - loadingView.frame.size.height) / 2.0;
[loadingView setCenter:CGPointMake(x, y)];

I did init my tableView with CGRectZero frame so it can take the whole place available on screen (which it did), but I thought its frame would update or something.

Any ideas ? Thanks !

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uitableview