My Project have 2 views 1. Mainview controller 2. Settingview Controller .
I want my main view controller to support all orientations but the setting view controller should be in landscape mode irrespective of the device orientation. Right now I am facing issues like
1. Even if the scene is in landscape mode the view appears as portrait
2. (BOOL)shouldAutorotate , (NSUInteger)supportedInterfaceOrientations not getting fired.
Any help is appreciated.
Related
I have two "pages" in my app. one which should rotate between the 2 landscape modes but not allow portrait mode and the other which should rotate between the 2 portrait modes but not allow landscape mode.
How can one set this up so that the orientations are limited correctly when segueing between the two views?
I will write my own segue if I were you and set the orientation of the destination view in the perform method of your custom UIStoryboardSegue and will also set the orientation i want to allow in the shouldAutorotateToInterfaceOrientationof the destination view controller. You can have a look to this question related to custom segue I asked some time ago to get an idea of how to implement custom segue.
When I'm in landscape mode on iPad and trying to launch app I'm getting strange behavior:
My root view controller view is created with dimensionality equal to 768x1024 whereas it should be 1024x768 (device is in landscape mode). Because of that my view hierarchy is corrupted.
View is created by the system (I'm using nib for interface).
Does it bug in iOS, or, maybe, I'm doing something wrong?
Edit: Autoresizing mask is default (everything resizes).
Found a solution here Reporting incorrect bounds in landscape Mode.
I was checking view controller view size in viewDidLoad, while correct sizes available only in viewDidAppear.
That is ok. It is always creates views in portrait orientation when perform rotation to lanscape. So U should implement
- (BOOL) shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)
- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)
And check in code
For a couple of different reasons, I'd like to ensure that my app only runs in landscape left orientation. I've unselected all of the other orientations under "Supported Device Orientations" in the target summary, set all of my storyboards to landscape, and added this to all of my classes:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
but I'm still having some problems. It launches into landscape left and that view remains in landscape left no matter what, but when I press a button that pushes a new view, it pushes the view but that one rotates if the device is turned. It also defaults back into portrait if I push another view and then press back in the navigation controller bar. Is there something more aggressive I need to do to ensure that all view controllers remain in landscape left at all times?
In my info plist, I have defined Supported interface orientations (iPad) as all orientations, and it works. The only problem is if I start in landscape mode, it starts as portrait, but If I rotate and then rotate back, it fixes.
So how can I make it so it adopts to the startup orientation?
thANKS.
You can force the orientation you need by implementing the following in either your didFinishLaunchingWithOptions: or in a view controller's viewWillAppear:.
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:NO];
The UIViewController that is installed as the root controller via [window addSubview:viewController.view]; should implement the shouldAutorotateToInterfaceOrientation function and return YES to all supported orientations.
The iPad starts the views with Portrait orientation and then rotates all the views by calling willRotateToInterfaceOrientation function with a duration of 0.
I noticed that the order of the interface orientations from the main .plist files is important also. E.g http://monosnap.com/image/jJeImyVp6G3Mq1uXLSAVRA0te2VwgJ Means that at startup the app will be in landscape, with the home button on the right.
I have some 10 view controllers contained in a TabBarController. We have a requirement wherein one view controller out of these 10 view controllers should always be displayed in landscape mode.
Now, when we override:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
and return YES only for Landscape mode in such view controllers, it has not effect. The view controller appears in Portrait mode only.
Probably this is done for a good reason, since when the user switches to a tab whose view controller should support only landscape mode, the whole screen components (including the tabbar) should be rotated to landscape mode, which looks awkward.
Am I right in assuming the cause?
Also, what would be the best way to tackle this? Provide an intermediate view controller in portrait mode and then push the landscape view controllers through it?
Thanks,
Raj