views:

113

answers:

2

Hi All,

i have an app that uses the iphone camera and puts an overlay over the camera. However it all works fine and i have managed to rotate the UIView to landscape but their is a 20px gap at the top of the view although i have set the positioning to (0,0,480,320).

starContainerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 480.0, 320.0)]     autorelease]; 
 UIImageView *overlayViewNew = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,480.0,320.0)];
 UIImage *OverlayImage = [[UIImage imageNamed:@"overlay.png"] autorelease];
 overlayViewNew.image = OverlayImage;
 [starContainerView addSubview:overlayViewNew];

so as you can see above i have set the UIView and set the UIIMageView and assigned a UIImage to that UIImageview and then added it to a subview of the view.

Here is the code i use to rotate the View.

- (void) accelerometer:(UIAccelerometer *)accelerometer
   didAccelerate:(UIAcceleration *)acceleration {


 if (fabsf(acceleration.x) > -1.0) {

   CGAffineTransform landscapeTransform =     CGAffineTransformMakeRotation(degreesToRadian(90));
  landscapeTransform = CGAffineTransformTranslate (landscapeTransform, +80.0, +100.0);

  [self.starContainerView setTransform:landscapeTransform];
 }

    }

I just cant seem to get it to fill that gap! Can i also say that no rocket science was involved whilst developing this but i still cant find the answer.

A: 

A 20px gap might have something to do with the status bar not being hidden properly. Make sure you have this in your info.plist:

<key>UIStatusBarHidden</key> 
<true />
Dave
Yes i have already got this enabled in the plist file. However it does look like it could be something to do with the status bar as it is that size.
SteveU
A: 

If was down to the following code. I played about with the figures below and this worked.

CGAffineTransform landscapeTransform =     CGAffineTransformMakeRotation(degreesToRadian(90)); 
  landscapeTransform = CGAffineTransformTranslate (landscapeTransform, +80.0, +80.0);
SteveU