I'm making an application for iPad in Xcode in template Master-detail application. I need to do a design for portrait mode and another for landscape mode. My first idea was make two UIViews and make a rule: if portrait, show View1, if landscape, show View2. But I have text fields in it and when the user will be typing something inside and then rotate the device, text will be deleted, because it will be another UIView... Can anybody help me, how to do it, please?
You can have one view and use springs and struts or use autolayout.
You can also add views and hide/show them based on the orientation change.
You can change the size and position of the view on orientation change.
Related
How to setup just one landscape view for whole app? I want to show only one view (qrcode) when phone is rotated independently in wich view this happened. What is the easiest way to do it?
My app is in portrait and I want show users code when it rotated to landscape in whatever view this was done.
See this answer. Just untick Portrait and tick on whatever Landscape orientation you want.
http://stackoverflow.com/a/29791531/7198143
Edit:
You should use Autolayout in your Storyboard to set up the right constraints so even in Landscape mode, the label for the code shows up. See this tutorial for more info.
Autolayout tutorial
I have a root view which contains a scroll view which contains a (content) view. The content view contains many child controls. Using the simulator, when I change orientation, none of the views, including the scroll view changes orientation. For example the image below starts out in portrait mode and all controls are played out correctly, but moving to landscape mode just shows portrait mode horizontally:
All of this was laid out using Interface Builder, so I don't have much code in the control view file besides some IB outlets to the controls.
Is there some sort of constraint that is preventing the reorientation of all the controls and views? Or do I always have to lay these out manually on orientation change?
First you need to check you have allowed the app to rotate by checking the orientations you want are ticked:
Click on the top-left corner (Show the Project Navigator)
Select the name of your project
See what is under General->Deployment Info->Device Orientation.
Adjust the tickboxes accordingly.
Update:
Also slide up on the simulator and check that rotation isn't locked for the device.
Try putting this in your AppDelegate/view controller:
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
(I don't think it's a constraint/layout issue as the status bar isn't even rotating)
really new to iPad development here. I made some mockups for what I'm trying to do.
I have a layout like so with options and menu at the bottom. When I rotate to landscape I want to get something like this:
In landscape the menu bar will always be on the right. In portrait always at the bottom. The contents of the square keep their position and rotation regardless of the device orientation.
What would be the rest way of going about this? I have considered removing all the views as the device begins to rotate and then replacing them using new coordinates. Doesn't seem like the animation will be smooth though. I understand how to do constraints, but I want the top square to stick to the tom when portrait and stick to the left when landscape, not always at the top. Any pointers on this would be really appreciated! thank you
This is a job for size classes. They let you define separate layouts for different orientations and would be an ideal solution for your problem. However, for some reason, the difference between iPad portrait and landscape orientation is not directly supported by the the current implementation of size classes.
There is a workaround, Sizing class for iPad portrait and Landscape Modes, that can redefine the meaning of the existing size classes to fit your problem. In other words, you can use the portrait and landscape size classes for the iPhone and re-map them so that they apply to the iPad.
They are selected by a 3x3 grid in Xcode’s Interface Builder. If you play with it a little, it’s easy to grasp the concept.
Here is a screen capture of the control in Interface Builder that lets you switch among your different layouts:
I am developing an app in IOS6. I am using storyboard and in my summary I have only portrait mode checked for Supported Interface Orientations. This allows my entire app to be locked into portrait mode without any extra programming.
In one of my viewControllers I have a subview (UIView) that is hidden and won't appear till a button is clicked. Once the button is clicked and the subview appears, it takes over the screen and displays images in a slideshow. I would like to make this subview have the ability to autoRotate because some of the images are in landscape. Is there a way to programatically allow this subview to be able to do this, even though the rest of the app is locked in portrait mode?
If you want to enable landscape in a single view controller and disable it elsewhere everything gets a bit complicated.
Essentially you need to set up all your view controllers to only allow portrait via supportedInterfaceOrientations. Then on your single view controller that you want to allow landscape on you can enable it via supportedInterfaceOrientations.
Lastly you then check all the supported orientations for your target.
Its a bit ugly but it works.
I created a split view controller application. I want to display my buttons and controls in landscape and portrait view differently(only the position).
When I change the orientation to landscape it shows the controls in portrait only. When I click on the cell in the tableview then it will show in correct position. What is the reason for that? Help me please.
I am a little confused about your question, but what I think you are trying to ask is how to change your view if the screen is in landscape or portrait orientation. Without seeing your code it is hard to tell you exactly how to do it, but the general idea (at least how I do it in my code) is that you want to split your code into two parts one that is in landscape orientation, and one that is in portrait orientation. You can tell the difference by seeing if the screen height is greater than the screen width.