0

My opening screen (my main app screen) is a UIView where everything is done programatically. I wanted to use an XIB for my "settings" screen, but I am getting a strange completely black bar at the top over the status bar:

Screen After Loading NIB

I switch to it as follows:

[[NSBundle mainBundle] loadNibNamed:@"ISViewController" owner:self options:nil];
self.view.transform = CGAffineTransformMakeRotation(-(M_PI * (90) / 180.0));
self.view.frame = [UIScreen mainScreen].applicationFrame;

I needed to rotate it, but even if I comment out the CGAffineTransformMakeRotation I still get the black bar. The XIB setting called "Status Bar" is set to "Light Content".

When I exit my XIB screen I use the following to get back to my original view:

self.view = jViewLayer;

But the black bar remains! Strangely, the view bounds have now actually shifted down by the height of the status bar too (this happens only after bringing up my XIB and then returning). This might be a clue of what is happening for someone trying to help me. Thanks all

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Narwhal
  • 744
  • 1
  • 8
  • 22
  • is `jViewLayer` a `UIView`? could you post some more code? did you try `[jViewLayer setFrame:CGRect(0,0,320,480)];` &/or (_if `UIView`_) then `[self.view addSubview:jViewLayer];` or (_if `UIViewController`_) then `[self.view setRootViewContoller:jViewLayer];` – staticVoidMan Nov 16 '13 at 19:52
  • jViewLayer is class of JoinerViewLayer, which is a subclass of **UIView** (because I need drawRect). I originally bring up jViewLayer view in loadView using this line: `jViewLayer = [[JoinerViewLayer alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];` That establishes the UIView frame correctly (before I bring up the NIB). I tried inserting this line `[jViewLayer setFrame:[UIScreen mainScreen].applicationFrame];` both before and after I have `self.view = jViewLayer;` but the same result (of course that also couldn't address the problem with the NIB screen). Thx – Narwhal Nov 16 '13 at 20:38

1 Answers1

0

I'm not sure I understand why, but I replaced the code above and using this code instead has resolved my issue:

[[NSBundle mainBundle] loadNibNamed:@"ISViewController" owner:self options:nil];
self.view.transform = CGAffineTransformMakeRotation(-(M_PI * (90) / 180.0));
CGRect menuNibFrame = CGRectMake(0, 0, 768, 1024);
self.view.frame = menuNibFrame;

There is something funky about [UIScreen mainScreen].applicationFrame] that I don't understand.

Narwhal
  • 744
  • 1
  • 8
  • 22
  • (**Note: *frame settings are respective to their superView***) When you do `self.view.frame = [UIScreen mainScreen].applicationFrame;` you're picking up a frame which basically equates to `CGRect(0,20,wwww,hhhh)`. The `applicationFrame` started at y=20 because it accounted for the top bar and then you were simply using the same frame settings. hence it left that 20px from top... which... is why, i advised `[jViewLayer setFrame:CGRect(0,0,320,480)];` in my previous comment. – staticVoidMan Nov 18 '13 at 06:13