When device turn to landscape, some controls go out of viewController, and I can't drag it to viewController.
Like you can see on your screenshot you have invalid constraints, this can be a problem. If you are using storyboard or xib simple use sizeclass to define specific constraints for portirat and landscape mode. Go and checkout Apple guidelines for adaptive UI https://developer.apple.com/design/adaptivity/
If you are using Storyboard with Autolayouts(constraints),Check once your constraints,Or if you are implementing via coding, You can change frame when device is rotating.
Related
I have a view that I want to look differently for landscape left and right, and I'd prefer not to have to deal with rotating all the subviews programatically. However, I don't see the option to different between landscape left and right in xcode. Am I just missing a switch or button somewhere, or is this not possible at all?
For clarity, I know you can do this programmatically using UIDeviceOrientation, but I prefer to keep all view layout work in my storyboards.
Unfortunately, this functionality does not exist as of Xcode 9.2
I want to present a UIViewController in iPhone and iPad both as same as we present in iPad using UIModalPresentationFormSheet but i also want to give good amount of curve on the edges like cornerRadius. I can do it using UIView and animate it from bottom to top but i want to do using UIViewController
It is not possible using the built-in frameworks.
Docs:
In a horizontally compact environment, this option behaves the same as
UIModalPresentationFullScreen.
You'll have to write custom code to show a view modally that doesn't fully obscure the underlying view.
in my universal app I have an UITableViewController embedded in a UINavigationController. When I add a UIView to the top of the tableView and insert a UILabel which is centered in the container, the label is only visible on iPhone but not on iPad.
I tried creating a new testapp, only consisting of these two controllers, the view and the label. It works on both, iPhone and iPad. So I added two new controllers to my app in the same way and made the navigation controller the initial view controller. Label is visible on iPhone but not on iPad.
For me it seems, that I have changed some global settings in the app; on another view I have similar problems with stackViews, but I first concentrate on this "simple" problem...
Any ideas what might be wrong in my app-settings?
tableViewController embedded in navigationController
Take a UIViewController embedded in a UINavigationController. Add View, Label, and TableView and check it
Ok. Now I know what was the problem. Never have checked, what's going on with those size classes.
During development I changed from any/any to a smaller size, not knowing, that this is not only taking effect on the layout in the storyboard. Everything I added after changing did'nt show on iPad.
Solution: Select storyboard, in "File Inspector", uncheck "Use Size Classes"
My iPad application is fixed on landscape, and can't be changed during the whole lifetime.
I setup the project as:
and then in storyboard, I set the orientation as the landscape, but I don't know why the view does not change to landscape?
Note: I am using Swift, XCode6.3.2, iOS8.1
In the any | component click on it and mouse over you can see the bottom text said the size of view for iPhone and iPad like following images.
if your application size class desable then that show direct reflaction like old way. but when your app size class enable that need to use with wAny hComponet
if size class enable with landscape:
Same if size class disable with landscape:
If you want to use size class then you need to check viewcontroller preview like following step:
Select view controller and then click on show the assistant editore.
Then you have two part on your xcode like following:
select a preview from following dropdown screenshot:
after select prview you can see the right side one view that is the preview of your viewcontroller view's you can change it landscape or portrait by following.
you can also check with all size by create new preview view by following.
In simulated metrics, you've got the size selected as Inferred. If you want to see what it looks like on a specific device type, select that from the first drop down list.
In the storyboard, the scene is universal so that you can use auto layout to adapt for various devices and orientations.
You can select iPad specifically from the simulated metrics:
Or you can, modify universal storyboard layout from the bottom panel.
Updated answer for Xcode 8 -
Click the View as: text at the bottom of the storyboard.
In my iPad app, the view controller include three button, one navigation bar and one tool bar.
When i rotate my view controller from portrait to landscape mode, three buttons are disorder.
The navigation bar also collapse to tool bar.
How can i do it?
You need to learn about layout. You can lay out subviews of your view in three ways:
Manually
Autoresizing (springs and struts)
Autolayout (constraints)
If this is a new project in Xcode 4.5 or later, you are using autolayout by default. So you need to go back into the nib and edit the constraints that Xcode already gave you, because obviously they are not what you want.
You might want to read the Layout section of my book, which has extensive discussion of how autolayout works and how to edit constraints in the nib: http://www.apeth.com/iOSBook/ch14.html#_layout
Ideally you should keep your content under one xib per view controller, linking your buttons and nav bars by pinning to your layout should rotate properly; however there is one other option for a viewing a different xib when the device is rotated, see the answer below.
Easiest way to support multiple orientations? How do I load a custom NIB when the application is in Landscape?