Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

resize content after iPhone status bar is shown/hidden

Tags:

ios

i have an iPhone application which I want to start with hidden status bar, to show a splash screen, and switch the status bar back in when the content to be shown is loaded (it takes some times since it has to be loaded over the internet), using [[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES]. I want my content view to resize and position itself properly after status bar is shown and hidden. I want my application to be able to run in any device orientation (maybe excluding the topdown orientation as specified in apple guidelines).

My problem is I can't get the application to appear as it should. Either it shows a 20pt blank space after autorotation or is hidden below the status bar when it appears.

What should be the proper way to handle this?

I haven't tested it yet, but i guess same issues would arise by the incoming call bar.

EDIT:

I'll try to explain better what the problem is. When the application starts it has status bar hidden, and in the window coordinate system the top corner of the window's visible area is 0,0 in the window's coordinate system. Then I slide in status bar. This doesn't change window size, hence 0,0 point is now hidden behind status bar. Top left of visible area of the window is 0,20 and I have to move my view to those coordinates (and resize it properly to 320 * 460). But if I rotate the device, then back to the original position, top left coordinate of visible window area becomes 0,0 again, and the window is now sized at 320 * 480.

A workaround is to keep a flag telling whether the phone has been rotated before, but isn't there a way to have the window coordinates not changing when I rotate to another position and then back?

like image 535
pqnet Avatar asked Nov 09 '11 15:11

pqnet


1 Answers

Yes, the same issues come up with the call bar. Alternatively, the audio recording bar does the same thing. (Its easier and maybe cheaper to start the voice memo app recording and come back to your app to test how it handles the extra bar.)

Setting the auto-resize masks on the view is what usually adjusts things for you.

If you are building your UI in XIB, you can play with the settings until your views properly change size when the bar changes or when the device or simulator rotates.

Remember that the mask settings on the contained subviews are important too.

like image 154
Walt Sellers Avatar answered Oct 13 '22 01:10

Walt Sellers