tags:

views:

2426

answers:

4

Dear all,

I found that after setting the

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO]

at viewDidLoad, then if I want to align an image to the top, I will need to set its position as .y = -20;

Is there anyway to make the y coordinate of the "top position" to "0" ? or is it doomed to be -20 after hidding the status bar?

Thanks for reading.

+2  A: 

I imagine you should add a UIStatusBarHidden item to the Info.plist if you want the status bar to be removed from start.

[email protected]

You also could look into setting the Autosizing to resize vertical (and horizontal)

See under Add A Text View here for example of what to click on in InterfaceBuilder

Quote:

Click the horizontal and vertical lines in the internal box so that they become solid red lines. The animated preview shows that the text view's internal size will grow and shrink with the window.

epatel
Many thanks for your reply, but it is doing no good to me.. setting it both to YES/true still unable to remove the status bar... and then I found that the code works instead of adding this key. I guess I must have done something wrong
Unreality
Oh I found that I have to set the value into boolean type first...
Unreality
+1  A: 

Check to make sure the size of your root view in your nib is properly set to 480x320. Some of the template project create those at 460x320 to account for the status bar. If you load a view that span full screen and the status bar is hidden, it should just work and you shouldn't need to do anything special at all.

Squeegy
Thanks for your reply, and I have already set it 480x320, but it's leaving a 20 pixels white space at the top afterwards.
Unreality
+4  A: 

I had a similar problem at one point and this bit of code fixed it for me:

[viewController.view setFrame: [viewController.view bounds]];
Justin Gallagher
So many thanks!!!! :)
Unreality
[self.view setFrame: [self.view bounds]]; <== I put this instead :)
Unreality
Using view.bounds (for me at least) correctly moves the view to 0,0, but still leaves a 20px gap at the *bottom* (noticeable because my view's background color is not white). This works: [self.view setFrame: [[UIScreen mainScreen] bounds]];
bmoeskau
+1  A: 

THANK YOU!!!!

I have been trying to figure this out for hours – a wrong size in the nib was the key to my issue!