I have a story board based iPhone application where the majority of the views are in Portrait mode, and should only ever be shown in portrait, due to the nature of the content. But then I have one view which should only ever be in landscape - how can I ensure that views are only displayed in the correct orientation?
I tried adding a second storyboard with the main storyboard set to Portrait orientation and the new storyboard set to landscape but if you launch the landscape view it appears in portrait mode. Can I forcibly rotate the view to landscape in viewWillAppear?
I tried setting the Target's build setting, orientation value to 'Portrait' and 'Landscape Left' but now been my portrait-only storyboard will auto rotate and screw up it's layout.
So, basically, how can I force a view to allow only one particular orientation (portrait for most of view, landscape for just one)?
Only one storyboard will do this. You need to do that ..
1- Go to inspector and select the view and then uncheck the autolayout.
2- Then click on size inspector top right on xcode file.
3- select your controlls one by one and resize them from Left,Right,Top and Bottom.
4- After that run your project.and see what happen....
Related
How to design ui in both portrait and landscape in interface builder in iphone or ipad (Iam using storyboard not xib..)..
Thanks in advance..
If you want design UI using storyboard, In latest iOS version there is option of Out Layout.
Using Autolayout you can manage UI for both modes.
Hope this will help you
http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2
Or
Other alternate provided on
iPhone Storyboard: different scene for portrait and landscape
When you add a view controller to the storyboard it comes with a view. Call that the container view. Add two views to the container view: a portrait view and a landscape view. Set the dimension of the portrait view and the landscape view appropriately using the size inspector. Add buttons, more views, labels or whatever to the portrait and landscape views as needed for your application. Then when the orientation changes hide one view and show the other.
Hope this will help you out.
I have an iPhone app that has several different view controllers. A login screen and then three other view controllers that contain table views. I am using the storyboard, not NIB files, and have designed each view in a portrait orientation on the storyboard. When I run my app, the login screen switches between landscape/portrait when I turn the device and looks just fine. However, the other screens do not change...well, actually they WILL change from landscape to portrait, but they won't change from portrait to landscape. If I am on the login view, then navigate to the other views I can see them in landscape, but as soon as I turn the device and it switches to portrait, it's stuck until I go back to the login screen.
I've searched and found answers that involve NIB files, but nothing about how to work with the device orientation when using the storyboard. Am I missing some property to set on the view? How can I get my table views to work like my login view and automatically switch the orientation automatically?
If you want to lock the view orientation in code you lock it with this:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == 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.
Is there any way when I rotate an iPad split view app that my view could take up the full screen instead of the menu or resize it? I like the portrait mode with the menu in the button.
How would I go about doing this?
If you're asking if you can hide the master view when a UIScrollView is rotated to landscape orientation, you can't. That's not what UIScrollView is for. You'll have to write your own view controller class.
All my app is in landscape mode .In some point I switch to a screen with Tab Bar Controller , but it's been placed like in portrait mode.I subclassed the UITabBarController and override the method "shouldAutorotateToInterfaceOrientation" to return YES always but because the app is already in landscape , this method is not being called.
does anyway have an answer to this?
thanks
Giald
You shouldn't have to subclass UITabBarController. The tab bar will autorotate to landscape, if all it's subviews support landscape. Just make sure all tabs support landscape orientation and you should be fine afaik.
Rengers is right, just make sure all tab views have YES in their respective shouldAutoRotateToInterfaceOrientation overrides. Depending on how you setup your app, check if any parent views have the shouldAutoRotateToInterfaceOrientation overrides. If so, it might be worthwhile commenting them out and leaving the overrides for the tab views only.