2

Possible Duplicate:
Hide the status bar on iPhone on a single view?

I want to hide the title bar in iphone from my first welcome view and also from the splash screen, how can i hide it(top bar, not the navigation bar).

I saw a post with this

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

but this hides the title bar through out the application. I just want to hide it from the first view.

Community
  • 1
  • 1
Raheel Sadiq
  • 9,847
  • 6
  • 42
  • 54

4 Answers4

4

The easiest way to hide the status bar is to go into youInfo.plist; right click to add a row and select Status Bar Initially hidden.

This will ensure every time you app launches the status bar will be hidden.

Edit

with programming

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
self.navigationController.navigationBar.frame = CGRectMake(0, 0, 320, 44);

and when you want to show the statusbar just use bellow code..

[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
self.navigationController.navigationBar.frame = CGRectMake(0, 45, 320, 44);

i hope this help you...

:)

Paras Joshi
  • 20,427
  • 11
  • 57
  • 70
  • i just want to hide it on my welcome view, it hide through out the app – Raheel Sadiq Oct 17 '12 at 12:53
  • [application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone]; or [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone]; try this with delegate class – Paras Joshi Oct 17 '12 at 12:58
  • Joshiyeah it worket great as my splashscreen and welcome screen were without status bar but as i do in viewWillDisappear " [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone]; " then the next view goes behind status bar not below – Raheel Sadiq Oct 17 '12 at 13:08
  • after try to set frame of view.. – Paras Joshi Oct 17 '12 at 13:10
  • also reloadInputViews , i think your navigationbar not set to Top but just try to set as top to view with frame (0,0,320,44).. :) – Paras Joshi Oct 17 '12 at 13:14
  • @mindFreezer see my edited new answer... – Paras Joshi Oct 17 '12 at 13:25
  • its gud but cannot do this view resizing thing on every view after welcome screen , :(, i am thinking dropping this feature – Raheel Sadiq Oct 17 '12 at 13:43
  • -(void)viewWillDisappear:(BOOL)animated{ [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone]; } – Paras Joshi Oct 18 '12 at 04:16
  • try in above method and upvote if its some helpfu; to you... and try to add setStatusBarHidden:NO in viewWillDisappear: its work for me – Paras Joshi Oct 18 '12 at 04:18
  • hahaha well your answer is true as well but my app situation not supporiting me , thanks – Raheel Sadiq Oct 18 '12 at 05:02
  • you are always wel-come mate.. :) but again any new problem occur?? – Paras Joshi Oct 18 '12 at 05:21
  • yeah, i have to set every view accordingly bcoz the view goes behind the title bar, so i left this things, coz already views are managed with difficulty, there is too much animation in my app, there is navigation bar and also tabbar, but i am hiding these with code , so there is already a mess – Raheel Sadiq Oct 18 '12 at 06:04
1

In AppDelegate class applicationDidFinishLaunching ,write the below code

- (void) applicationDidFinishLaunching:(UIApplication *)application
{
    [[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
}

All other views (except first View) when you need to display StatusBar, write the below code in curresponding ViewDidiLoad() / viewWillAppear,

[[UIApplication sharedApplication] setStatusBarHidden:NO animated:NO];
Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102
  • it seemed great, when i read, but then i did like this, it gave me message that it is deprecated, although it did hide and displayed the status bar, but when i navigated to next page, the status bar was over my view and the my view was behind it not below it, any idea? – Raheel Sadiq Oct 17 '12 at 12:51
1

in your info.pist find this option. "Status bar is initially hidden" And set as YES.

Ayaz
  • 1,398
  • 15
  • 29
0

Depends which version of Xcode you are using.

In 4.5 you can go into the build settings "Summary" tab and set this in the "Status Bar" section.

If you don't have 4.5 then in the build settings "Info" section add a plist entry for "Status Bar Is Initially Hidden" and set it to YES. (Alternatively, download Xcode 4.5 because you should do this anyway).

Fogmeister
  • 76,236
  • 42
  • 207
  • 306