Reputation: 26223
From within rootController
I am manually adding a UITableView, but I don't know how I would get the frame size ...
Controller *rootController = [[Controller alloc] init];
UINavigationController *tempNavController = [[UINavigationController alloc] initWithRootViewController:rootController];
[self setNavController:tempNavController];
[tempNavController release];
[window addSubview:[[self navController] view]];
[window makeKeyAndVisible];
I am currently using: [[[self navigationController] view] frame]
but this does not account for the "navBar" height or that of the "statusBar" (giving me: 480). Is there a way to get the size of the frame below the statusBar / navBar or do I have to subtract 20 + 44 off the number above?
NB: I am using navigationController.navigationBar.frame.size.height
to get 44
Upvotes: 21
Views: 23150
Reputation: 30573
safeAreaLayoutGuide When the view is visible onscreen, this guide reflects the portion of the view that is not covered by navigation bars, tab bars, toolbars, and other ancestor views. (In tvOS, the safe area reflects the area not covered the screen's bezel.) If the view is not currently installed in a view hierarchy, or is not yet visible onscreen, the layout guide edges are equal to the edges of the view.
So you can use:
self.safeAreaLayoutGuide.layoutFrame
Upvotes: 2
Reputation: 18670
You can try to subtract
[UIApplication sharedApplication].statusBarFrame.size.height
And
self.navigationController.navigationBar.frame.size.height
From your
self.window.frame.size.height
Cheers, Rog
Upvotes: 48