Problem with hiding status bar on iphone app, screenshot included
Im getting this blue line when i try to hide the status bar, I'm using the following line in the touchesBegan method in my RootViewController
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBa开发者_如何学运维rAnimationFade];
http://i.stack.imgur.com/GBCgX.png
Thiis is really simple. forget about coding it. just do it right at the beginning this make it a lot more simple and less messier. I do it all the time for every single application I've created.
Go into your project in xcode, then in the Groups and Files section find a file called yourapplicationname-info.plist.
Double cick that and a box opens. It contains properties for your file in the form of a table. Click on the last row once so that the last row is highlighted in blue. Click on the plus arrow on the right end. This will add a new row. A list appears, scroll down to Status bar is initially hidden and click enter to select it. Then an empty box appears next to the name. Tick the box and click CDM+S to save the plist. close the box and get back into xcode. Now take your code off where you try to hide the status bar.
Then click on the view, the .xib file and click with your mouse the actual view so it is in focus (the window that we are currently looking at). Then hit cmd+3 to open up the attributes section. Where it says status bar select the option and select unspecified. Now this will get rid of the status bar on the uiview. What might happen after selecting that optiion is decrease the size of the actual view by 20 pixels. thats the height of the status bar. what you want to do is readjust the view to compensate for the missing status bar. so while still having the view in our focus. hit cmd+3 this will open up the view size. change the H (height) from 300 to 320. And this will readust the screen by adding the 20 pixels which we lost by removing the status bar. Then save and close interface builder and youre done.
Hope this helps Let me know if it does. Thanks
PK
If your view controller is embedded in a nav controller:
[CODE]self.navigationController.navigationBar.frame = CGRectOffset(self.navigationController.navigationBar.frame, 0.0, -20.0);[/CODE]
Put that in the view did load method on the first view controller your app sees. Finally a solution to this frustrating problem!!!!!
It looks like you have to adjust you view to take up the space formerly occupied by the status bar. You can probably do this using springs and struts in Interface Builder, or you can adjust the view's frame just before or after your call to setStatusBar: withAnimation:
.
k then you have to do in appdelegate class
[application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
it works fine for me... hope this will help you≥
精彩评论