My Parent View is in Portrait Mode, but i want my next View to be in Landscape Mode. But i'm unable to achieve this. For making the Next View in Landscape Mode i have to give support to my Parent View as Landscape too which i don't want. Any Suggestions????
Thanks in Advance
In your next view, call
[UIApplication setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:YES]
to set it in landscape orientation.
Related
I have two viewcontrollers, ViewControllerA supports both landscape and portrait, click a button in ViewControllerA push into ViewControllerB, which supports landscape only, then I make the phone in the landscape direction and then pop back to ViewControllerA, by default A is in landscape mode now, but I want it to be portrait first in this situation. How can I implement that?
In your ViewControllerA's viewwillappear method set the orientation like
[[UIDevice currentDevice]setOrientation:UIInterfaceOrientationPortrait];
I have 2 button .In first button I used separate view for landscape and portrait and for the second button I use only one view for both portrait and landscape. But when I click on button 2, it get load on portrait view then orientation to the landscape mode it load the first buttons landscape mode.
I think u used CGRect class for button1 views.
use separate functions for Landscape mode and portrait mode.
I think this will be useful for you.
I have a UITabBar with 2 bar items. The initial orientation of the device is portrait. If I rotate the device to landscape while being at tabBarItem2 the whole thing(Status Bar, TabBar, ViewContent2) rotates fine, but when I press the tabBarItem1 the ViewContent1 is still in Portrait. It also happens if I'm in tabBarItem1, then rotate device to landscape and I go to tabBarItem2.
I'm using the willRotateToInterfaceOrientation method on each view controller to move things.
I think this is happening because it is triggering the actual viewController's willRotateToInterfaceOrientation method and not on both of them.
Any ideas on how to fix that?
Both view controllers need to have
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
I have an application which is focused around a bunch of viewControllers in portraitmode, but on a specific detail view i need to open another view if the device is rotated to landscape mode.
So the user will look at the information view in portraitmode and if the user then rotates the device to landscapemode then a new view is displayed with additional information. If the user rotates back to portrait then the added view needs to be removed so the "original" detailview is visible.
It's important that the "original" detailview is not rotated to landscape - Only open a new view in landscape mode.
I've tried using shouldAutorotateToInterfaceOrientation: and managed to have it open a viewController, but it's not being shown in landscape view so it looks all messed up plus I'm having some trouble getting the view to disappear when i rotate back to portraitmode.
How do i do this?
Check if the orientation has changed using the View controllers did change orientation methods and if its rotated to landscape add ur landscape view and when the device is rotated to portrait remove the view from the view controller's view.
in shouldAutorotateToInterfaceOrientation
if(UIInterfaceOrientation == UIInterfaceOrientationPortrait){
NewView *newViewController = [[NewView alloc]initWithNib:#"NewView" bundle:nil];
[self.navigationController pushViewController:newViewController animated:NO];
}
you can repeat this for all the other orientations as well.
Using shouldAutoRotate didn't work since the view that gets opened will be opened in portraitmode and not landscape.
I ended up with a solution using beginGeneratingDeviceOrientationNotifications and shouldAutoRotate in the subview.
I have a UINavigationController-based app that only supports portrait, but need to push one view that requires landscape. I've found a previous post that describes how to allow mixed rotations for a single view, but what is the process for forcing a single view, when pushed, to be in landscape then returning the app to portrait mode when the view is popped.
Thanks!
You cannot force an orientation change just by pushing onto the nav stack. What you can do instead is present the view controller which must be landscape as a modal view controller instead.