views:

4642

answers:

2

I think the title is pretty descriptive:

I perform all 3 of these operations on a view, the result is 20 pixels of white space along the left side of the screen (if holding the iPhone is landscapeLeft).

I tried to fix it by performing a CGAffineTransFormTranslate(transform, -20, 0)

That just "slides" the view underneath the whitespace.

This is starting to feel like a bug, anyone else have this issue?

To clarify, I am not rotating any views. I am sensing the orientation of the device:

[[UIDevice currentDevice] orientation]

And if the device (not interface) is in landscape, then:

[navigationController presentModalViewController:NewView animated:NO]

The transform is to rotate my view (created in IB) to landscape, before displaying it.

My Transform code:

    CGRect myFrame = CGRectMake(0, 0, 480, 320);
    CGAffineTransform transform = [[self.myPeriodicTableViewController view] transform];
    transform = CGAffineTransformRotate(transform, degreesToRadians(rotationDirection * 90));
    transform =  CGAffineTransformTranslate(transform, -20, 0);
    [[self.myPeriodicTableViewController view] setFrame: myFrame];
    CGPoint center = CGPointMake(myFrame.size.height/2.0, myFrame.size.width/2.0);
    [[self.myPeriodicTableViewController view] setTransform: transform];
    [[self.myPeriodicTableViewController view] setCenter: center];
+4  A: 

I think you may need to recenter your center:

// Set the center point of the view to the center point of the window's content area.      
self.view.center = CGPointMake(160.0, 240.0);

This is the whole init method I use for landscape views and works without an issue. Just make sure to set your nib to the right size too.

// Implement viewDidLoad to do additional setup after loading the view.
- (void)viewDidLoad {
  [super viewDidLoad];

  // Rotate to landscape
  self.view.frame = CGRectMake(0, 0, 480.0, 320.0);
  if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight) {
    CGAffineTransform transform = self.view.transform;

    // Set the center point of the view to the center point of the window's content area.      
    self.view.center = CGPointMake(160.0, 240.0);

    // Rotate the view 90 degrees around its new center point.
    transform = CGAffineTransformRotate(transform, (M_PI / 2.0));
    self.view.transform = transform;
  }
}
Squeegy
Thanks, I added my transform code, I reset the center. No mater how I manipulate the frame, the white space "overlays" my view. Even if my view's origin at (0,0), the white space obscures my view. It doesn't seem to be a problem with the transform, just from mixing status bar and modal view commands
Corey Floyd
I just check my NIB size, and the width was only 300, so changed it to 320. The problem still persists.
Corey Floyd
Also my transform code is in my App delegate, and is executed after the push. if I do it in viewDidLoad, I get odd results
Corey Floyd
+2  A: 

Ok, I figured it out. As usual it was the result of more than 1 issue. These problems all occur before I even push the modal view:

First, In my code I was resizing my view like so:

[self.view setFrame: [[UIScreen mainScreen] applicationFrame]];

After you hide the status bar, applicationFrame STILL returns a 320x460 rect (not 320x480). Not sure why, but the following fixes it:

[self.view setFrame: [[UIScreen mainScreen] bounds]];

This gets the whole screen which I lifted from:

http://stackoverflow.com/questions/373791/fullscreen-uiview-with-status-bar-and-navigation-bar-overlay-on-the-top

Second, and in the same line of code, I am not talking to the correct viewController. Since I am in a Navigation Based app, I must talk to the NavigationController. If not, the Navigation Bar never gets the message to move to the top of the screen to cover the space left by the status bar (which resulted in my white space). So one more correction to this line of code:

  [[self.navigationController view] setFrame: [[UIScreen mainScreen] bounds]];

Lastly, after all of this, I can push my modal view with confidence.

Corey Floyd