I'm going in circles here. I have set shouldAutoRotateToInterfaceOrientation for all the view controllers. My app is running correctly in landscape, like this:alt text http://img517.imageshack.us/img517/3749/screenshot20100701at802.png
However, when I add a new subview using [window addSubview:whatever.view]; it shows up like this:alt text http://img291.imageshack.us/img291/3749/screenshot20100701at802.png
How can I make the new subview automatically be added in landscape orientation?
Thanks!
window is probably not managed by one of your view controllers that implement shouldAutoRotateToInterfaceOrientation.
Add your view to one of your view controllers that implement the autorotation.
Related
I have a Navigation Controller and TabBar. I would like to know how the iPod app handles allowing only the play screen to rotate. I have tried to replicate this on iOS 4.2, and if that one screen rotates to landscape and you navigate back, the old screen is too. This is undesired... is there anyway to make the 2nd screen in rotate while not causing the rest of the screens or any of the TabBars view controllers elsewhere do so?
Thanks.
Make sure your rotatable view returns YES in shouldAutorotateToInterfaceOrientation: method of UIViewController.
Make sure your non rotatable view returns NO in shouldAutorotateToInterfaceOrientation: method of UIViewController.
Subclass UITabBarController, override shouldAutorotateToInterfaceOrientation: and handle rotation here based on current UIViewController's shouldAutorotateToInterfaceOrientation: return value. You have to also check if current view controller is UINavigationController or not and if yes, you have to get current view controller from UINavigationController too.
It's not recommended to do this (I mean subclassing of UITabBarController), but UITabBarController forbids rotation if not all UIViewControllers do allow rotation.
You need to state that in the 2nd screen the device orientation is only the desired screen orientation. So for every controller you create you need to implement shouldautorotatetointerfaceorientation:.
I have a UITabViewController application with 4 tabs and each tab with a UINavigationController, each with a UItableView. When a row is clicked it navigates to another view.
I would like to support Landscape Orientation only for a certain UIViewController and not in any other view.
When I set "return YES" on each UINavigationcontrollers (BOOL)shouldAutorotateToInterfaceOrientation: method the app orients in all the views even in the uitableview.
How do I get this right? I am very confused
If you want to maintain the views as per your requirement then you have to make different view for each tab also in Interface builder you have to create landscape view wherever you required. When you add that landscape view, which is created in interface builder will be shown as landscape only. There will be no need of shouldAutorotateInterfaceOrientation method.
I have a view controller which manages a view.
I'm adding the my view controller subclass as a subview of the window swapping out another view.
I'm running landscape mode on an iPad.
The view apparently doesn't know that its in landscape mode. Its frame is confused.
Is there something I can/should do to tell it that its in landscape, and/or that the orientation has changed. How does this normally happen. Why isn't it happening?
I used to have my view controller within a UITabBarController and it worked fine there.
Override:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return YES;
}
Your ViewController is not getting rotation events because you have not presented the viewController but have added the viewController's view in the view hierarchy.
Your Tab bar controller previously used to take the responsibility to forward the rotation events to the view controller which it manages, that was how it used to work.
I would though suggest that swapping the view out of window is a bad idea. Instead you should have a main viewController which accepts the rotation events and then swap the view within this viewController based on the current orientation. Consider re-desiging before you code further.
My problem was that my storyboard was overriding my existing custom coded app delegate. After I deleted the story board file, and custom generated view controller code, it worked for me.
I have a subclass of UITabBarController which i am using so that i can rotate to use my app in landscape too.
How would i go about rotating my UI and getting each view controller to use a landscape view xib?
I have always just written apps before where returning YES for shouldAutorotate... handles it automatically for me... this isn't the case here now, as i'm using a custom view.
Thanks.
You don't need to subclass UITabBarController to get the autorotation behavior. Instead what you should do is have ALL the UIViewControllers that appear in your UITabBarController return YES for shouldAutorotateToInterfaceOrientation:. If even one of them does not, the UITabBarController will not autorotate.
As for the custom view, it is associated with a UIViewController, right? If so, then if your custom view implements layoutSubviews using the current view bounds to lay out all the subviews, then it should autorotate correctly as well.
I have a UITabbarController with (so far) two navigation controller items. I can get the application to rotate by adding the shouldAutorotateToInterfaceOrientation to each class... but thats not exactly what I want.
What I want to do is to add a button in the UINavigationBar in one of the classes. When this button is pressed I want it to load another view into landscape mode. This view should not show any navigationbar or tabbar controller.
How can I get this to work?
Best regards,
Paul Peelen
You can try to use approach similar to Apple's AlternateViews sample.
Basically you should:
Create your landscape view with appropriate size (480x300 for landscape if standard statusbar is visible)
In your button handler push your landscape calling -pushModalViewController on your current view controller
Apply necessary affine transformation to your view to be displayed correctly in landscape.
Use presentModalViewController:animated: and implement the modal view controller's shouldAutorotateToInterfaceOrientation: accordingly.