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 !
I managed to estimate to frame programatically. I didn't mentionned that my tableView was between a navigationBar and a tabBar, so here is the code for this case :
CGFloat x = self.navigationController.view.frame.size.width;
CGFloat y = self.navigationController.view.frame.size.height -
self.tabBarController.tabBar.frame.size.height;
self.tableView = [[UITableViewController alloc] initWithFrame:CGRectMake(0.0, 0.0, x, y)];
And the code posted above for the positionning of the loadingView works like a charm !
I'm open ton better solutions, of course