Place a UIView in the middle of a UITableView with the CGRectZero framework

I have a UITableViewController to view the UITableView, which I highlight / init with the CGRectZero framework:

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

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

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 initialized my tableView with the CGRectZero framework so that it could display all the place on the screen (which he did), but I thought that its frame would be updated or something else.

Any ideas? Thank!

+3
source share
3 answers

. , tableView tabBar, :

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)];

, loadView, !

,

+2

DownloadView , . , , , , TableView:

- (void)show
{
    self.center = targetView.center;
    [[targetView superview] addSubview:self];
}

LoadView KVO UITableView .

+1

UITableViewController, , UIViewController.

UIViewController?

, self UITableViewController:

loadingView.center = self.view.center;
0
source

Source: https://habr.com/ru/post/1739586/


All Articles