1

I'm making use of [[UIScreen mainScreen] bounds] for the basis of framing a lot of sub-views. I'm also making use of values from [[UIApplication sharedApplication] statusBarFrame] and self.navigationController.toolbar.frame to ultimately determine the framing of useful view space I can make use of in the app.

I'm seeing problems as I try to handle device rotation. With some debugging, I'm learning that the values I get from the methods above aren't necessarily what I'm looking for.

In short, no matter the device rotation, I'm ultimately looking for the size of the view (screen minus status and navigation control toolbar) that is my working area. How do you advise I obtain this size/frame?

Thanks.

Steven
  • 1,049
  • 2
  • 14
  • 32
  • Resolved this by following information on this post - http://stackoverflow.com/q/7905432/870345 – Steven Apr 26 '12 at 08:14

2 Answers2

1

Resolved this by following information on this post - stackoverflow.com/q/7905432/870345. My code:

- (CGSize)currentSize
{
    CGSize size = [UIScreen mainScreen].bounds.size;
    UIApplication *application = [UIApplication sharedApplication];
    if (UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
        size = CGSizeMake(size.height, size.width);
    }
    if (application.statusBarHidden == NO) {
        size.height -= MIN(application.statusBarFrame.size.width, application.statusBarFrame.size.height);
    }
    size.height -= self.navigationController.navigationBar.frame.size.height;
    return size;
}
Steven
  • 1,049
  • 2
  • 14
  • 32
0

Probably not he best way, but you could drop a UIView on your view and set its springs and struts so that it autosizes and stays full screen. Then get the frame via outlet to this view.

Mario
  • 4,530
  • 1
  • 21
  • 32
  • Thanks. Sure, I think your method would work, but as you say, I think dropping a empty view is not optimal. I'm gonna hold out for a more straightforward method to this, from the community. What I'm trying to do must be done by a *lot* of apps out there. – Steven Apr 25 '12 at 17:30