Madhuri
Madhuri

Reputation: 178

setStatusBarOrientation not working

I'm trying to fix the orientation of status bar to Portrait, but not succeeded. I have tried:

[application setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO]; 

and also shouldAutorotateToInterfaceOrientation is set to return NO.

Please help me out.

Upvotes: 0

Views: 2287

Answers (1)

Paresh Navadiya
Paresh Navadiya

Reputation: 38249

If you want to change the orientation when a particular view is showing, you should call [UIApplication setStatusBarOrientation:animated:] inside your [UIViewController viewWillAppear:] override method for each of the view controllers that force a particular orientation. That will cause a change when a view is being pushed onto the stack and when it's being popped off it. Make sure you call super in your override method.

Also change your shouldAutorotateToInterfaceOrientation method:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
   return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}

Upvotes: 1

Related Questions