Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Frame size below navigation bar?

Tags:

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

like image 948
fuzzygoat Avatar asked Dec 07 '10 16:12

fuzzygoat


2 Answers

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

like image 111
Rog Avatar answered Oct 25 '22 13:10

Rog


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 
like image 20
malhal Avatar answered Oct 25 '22 15:10

malhal