UIStatusbar changes orientation, but everything else stays the same - iphone

I have a tabbar app, with some uinavigationcontrollers.
In every VC i have:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
But for some reason when rotating the screen the status bar rotates, but the rest of my view stays the same. How can I fix this?

Try adding this to your info.plist

shouldAutorotateToInterfaceOrientation: would normally be implemented like this (for an iPhone app that supports rotation):
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
It's not clear from your question whether you want the subviews to rotate or the status bar to not rotate.

Related

Keep all views portrait except one

Right I have done a lot of research on this and have hit a block.
I am developing an app which has multiple view controllers. I have the 'homepage', if you will, which all the others views can be access from (this ViewController.m). I also then have a UINavigationController.m attached to the ViewController.m to allow a full navigation bar etc.
My problem is that I am wanting all views to be shown in portrait EXCEPT one view, which I only want in landscape. In my app options, I have set it to enable all orientations and then I was reading that you should override the main orientation in your root view controller (which I assume is the navigation controller?), so I add:
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
This overrides everything and only portrait works. I have then tried adding:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
To the view that I want to have in landscape only but it fails to work in the simulator.
Can anyone provide me with a solution? :/
(I would like iOS5 and iOS6 support if possible)
[EDIT]
I should add, I haven't edited AppDelegate in any way.

how to enable rotation only on video

I've been looking for the past days a solution to enable rotation ONLY when MPMoviePlayerViewController is triggered, without any luck.
I tried to enable the app to all rotations, and disabling it at each view, but it didn't work either.
does any one have an idea?
In target settings, enable all orientations
(optional, UIViewController default is portrait only) In all the other view controllers, do the following:
// Deprecated in iOS 6, but still needed for earlier versions of iOS:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
// For iOS 6 and up
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
In the one view controller that should rotate, do the following:
// Deprecated in iOS 6, but still needed for earlier versions of iOS:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
// For iOS 6 and up
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
This is assuming the rotating view controller will not be inside the same container view controller (such as UINavigationController or UITabBarController) as the non-rotating view controllers.
Create a new ViewController for the player Full screen and add:
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
to your code.
Make sure you present the ViewController.
(supporting iOS 6 and above)

Orientation iOS storyboard don't rotate?

OKay, this is probably pretty noob, but I couldn't find how to solve it.
I dragged an iPad UIViewController to the storyboard and enabled the orientation to YES. But for some reason that view is not rotating. The status bar at the top is rotating but the view, tableview and labels inside are not rotating when you rotate the iPad. Anyone know why and how to fix it?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOr‌​ientation { return YES; }
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
//return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
if ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight)) {
//implement your code
return (interfaceOrientation != UIInterfaceOrientationLandscapeRight);
} else {
return YES;
}
}
I think it will be helpful to you.
The status bar rotating might mean that some modal segue was not dismissed properly just check. Also if its in a navigation controller make sure all views in the stack has been set to return YES.

How To Restrict Changing Into Landscape Iphone?

I do have five view controllers, and i am navigating from first view Controller to end view Controller (fifth view controller)
In middle i do third view i need to do orientation. for landscape and potrait mode.
and from there it need to be potrait mode only.
I added this delegate method for orientation in fouth viewController . but its not effecting
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
//Support orientation for Portrait
return (interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown || interfaceOrientation==UIInterfaceOrientationPortrait );
}
I think your changing orientation in your first view.Open your third view and write this method then change whatever you want...i think you should write this in all of the view expect third view...
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Now in your third view write your code....
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
//Support orientation for Portrait
return NO;
}
just do.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (interfaceOrientation == UIInterfaceOrientationLandscape)
return NO;
else
return YES;
}

Fixing the orientation of view controllers

I have a button in my RootViewController ....
when i click on this button it will navigate to some otherViewController.
but i want that when i click on the Button otherViewController's Orientation should be Landscape
& when i back from this page(otherViewController) i should got again Portrait mode.
lots of Thanks for any help.
Plz help me i m new in Iphone so can't able to handle this.
Note in iOS 6 shouldAutorotateToInterfaceOrientation is deprecated. Instead you should use supportedInterfaceOrientations and return a UIInterfaceOrientationMask.
So for example:
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
Here are all the UIInterfaceOrientationMask options you might return:
UIInterfaceOrientationMaskAll
UIInterfaceOrientationMaskAllButUpsideDown
UIInterfaceOrientationMaskLandscape
UIInterfaceOrientationMaskLandscapeLeft
UIInterfaceOrientationMaskLandscapeRight
UIInterfaceOrientationMaskPortrait
UIInterfaceOrientationMaskPortraitUpsideDown
You should also consider the preferredInterfaceOrientationForPresentation.
In general, orientation should only change from portrait to landscape (or vice versa) when the user rotates the device.
However, if you want your RootViewController to always present its view in portrait and your OtherViewController to always present itvs view in landscape, that's easy enough.
In your RootViewController's .h:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
In your OtherViewController's .h:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
Although this would probably be better as it would allow both landscape-left and landscape-right rotations:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
The only way I am aware this can be done is by presenting otherViewController modally.
See my answer here: UIViewController loads rotated to landscape but only supports portrait
Maybe it helps.
in viewWillAppear of your new view controller add
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscape]
and in viewWillAppear of your root viewController add
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
It will cause warning but it works.