0

I am having a rather trivial example, where I compose a pretty simple layout:

- (void)applicationDidFinishLaunching:(UIApplication *)application
{
   self.window.rootViewController = self.someController;
   ...

Now the problem is, that the content of my viewcontroller is below the statusbar (20px).

Is the recommended way to manually resize my viewcontroller and move it 20px to the bottom, or is there any smarter way of handling this?

Note: I do not want to use e.g. UINavigationController.

[edit] To clarify, some more code:

 - (void)applicationDidFinishLaunching:(UIApplication *)application
 {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    self.menuController = [[MenuController alloc] init];
    CalendarViewController* center = [[[CalendarViewController alloc] init] autorelease];
    IIViewDeckController* rootController = [[IIViewDeckController alloc] initWithCenterViewController:center leftViewController:self.menuController];

    rootController.leftLedge = [[UIScreen mainScreen] bounds].size.width - 320.0;
    rootController.delegate= self.menuController;

    self.window.rootViewController = rootController;

    [self.window makeKeyAndVisible];
 }

As you can see, I'm using the IIViewDeckController (Link) as root controller. Currently it looks like this:

Screenshot

user826955
  • 3,137
  • 2
  • 30
  • 71
  • Not sure if this helps but have you tried `self.edgesForExtendedLayout = UIRectEdgeNone;` in your viewController ? – Zhang Nov 24 '14 at 09:16
  • Please give a look at this link http://stackoverflow.com/questions/17074365/status-bar-and-navigation-bar-appear-over-my-views-bounds-in-ios-7 – Monikanta Nov 24 '14 at 11:59
  • Did not change anything at all – user826955 Nov 24 '14 at 21:14
  • @ecnepsnai: none of the solutions/examples seem to fit my case, since I dont have iOS 6/7 issues (I can be 7 only), and I dont have any navigation controller. – user826955 Nov 25 '14 at 07:05

2 Answers2

1

Use this code in viewDidLoad

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    if([self respondsToSelector:@selector(edgesForExtendedLayout)])
        self.edgesForExtendedLayout=UIRectEdgeNone;
}

Please let me know if you are still facing the same problem.

chandan
  • 2,453
  • 23
  • 31
1

The correct way to do this is to align all your views to the topLayoutGuide of the view controller. The layout guide will handle pushing your views down for the status bar, the in-call bar and if you move to a navigation controller later.

John Grant
  • 1,679
  • 10
  • 8
  • Can you please give a simple example of how doing this programatically? I'm not using IB/storyboard, and this is a rather old existing app I dont want to convert. I found some hints in the apple docs about this already, but I failed to come up with a concrete idea of how to add this to my app in the correct way. – user826955 Nov 25 '14 at 07:04
  • How are you adding your views right now to your view controllers? Are you just adding them in the viewDidLoad call? Are you using autoLayout? – John Grant Nov 25 '14 at 12:08
  • The `topLayoutGuide` works really well with auto-layout. If you're not yet using auto-layout, and don't want to transition yet, then I would recommend adding a "container view" to put all your content in with the appropriate resizing masks. Then you can use auto-layout on that container view to align the top of that container to the the `topLayoutGuide` – John Grant Nov 25 '14 at 14:02
  • Its not my code, its from `IIViewDeckController`. The code is here: https://github.com/Inferis/ViewDeck/blob/master/ViewDeck/IIViewDeckController.m – user826955 Nov 27 '14 at 12:28