I have a logo in the storyboard set to a top constraint of value 28 and it works for all devices. On iPhone X device it merges with the camera bar on the top. If i increase the top constraint it affects the other devices. How do i set a constraint only for iPhone X alone?
By default Xcode provides you with a Safe Area upon project creation.
Here, I've added a UIView with the following constraints. Take note of how the constraints are pinned to the Safe Area, and not the Superview.
Running the app, you'll see that the view respects the status bar across all devices.
Hope this helps with the issue you're having...
Related
enter image description here
I have set the constraints from the safe area for every labels and textfields but the problem is still occurring. The app perfectly sets only on iphone 11 and iphone 12 simulators only.
(Have shared the screenshot)
I have set the constraints from the safe area for every labels and textfields
No, you don't. If you did, you would not have this problem. You have not correctly set the trailing constraints for these views. In fact, it looks like none of your views has correct constraints.
Every view must be completely configured through constraints as to its position and its size. It must, in other words, be bounded top, left, bottom, and right. Labels and text fields and buttons have an automatic height so you don't need to fix their bottoms, but all of your views need top, left, and right constraints.
In my application i have a screen which contains close button on top and program information at bottom and both trailing,leading,bottom and top constraints related to safe area.
Button width and height is 1:1. Program info area height is 0.25 of view height. In run time adding avplayerviewcontroller view on screen whose height is 75% of self.view.It's working fine in all device except iPhone X. If i launch app in landscape then alignment is fine and if I change orientation I can see 44 pixels as x value. If I launch app in portrait first then portrait orientation values are correct if I change orientation to landscape then 44 pixels top(y) value is adding. I am not getting how to fix this issue. Please guide me.
[![enter image description here][1]][1]
I guess your problem is that you have defined constraints in percentages, which might be an issue. When you rotate the screen the mid section might be too small. Have you tried the rotated layout in interface builder to see what is happening? Defining layouts with constraints is relatively easy in interface builder and you can test the layouts as well.
If you programmatically set the constraints, it is hard to find out where it went wrong. If you have one ambiguous constraint, the whole screen can be weird.
If you need to make programmatically set constraints, you should make a test setup in interface builder and implement the good setting in the program code, when everything works as planned.
I have checked your storyboard and I think the issue might be that you have two safe area defined. One outside the containerview and one inside. What you put inside the container view, might be wrongly calculating the constraints inside.
Try to take out this checkbox and try it again.
I added constraints properly with respect to super view instead of a safe area but still I am facing an issue of grey area on top and bottom of specific screen.it should appear completely on the whole screen at I Phone X. Please follow the screenshot.
Check that you have a launch storyboard and not a fixed launch image
that does not respect the iphone x screen size
Check in your top and bottom constraint properties that they are relative to superview and not to margins (by default xcode 9 adds the constraints relative to margin).
After upgrade my xcode to 7 I am getting the issue in autolayout. I have put a container in view controller for which I set the leading and the equals width to parent view (it means that I need container on full width of screen) every thing has working fine but the issue is with the leading constraint of that container. I have to set the leading constraint constant to -20 then it would be looks perfect on 6plus, but for all other devices -16 would do the same result.
The most easiest way is to resolve your issue is by going to your Storyboard scene or nib file click on topmost view in hierarchy and finally click on Resolve auto layout Issues button from the four option available at bottom right corner and update frames.
Xcode will take care of rest.
This is happening because from Xcode 7 iOS 9, Apple wants us to leave leading or trailing space at-least by 20 points for UI perspective.
I think it would be easier to add spacing constraints from your container to the super view. If you define Leading Space, Trailing Space, Top Space, and Bottom Space as "0" without margin the container should have the exact size of your device regardless of the iOs version and device type.
I'm using Auto Layout for an iPhone app to place a button footer bar at the bottom of the screen on both 3.5" and 4" iPhones. The bar is a UIView containing two UIButtons and a UIImageView.
I have a Vertical Space Constraint pinning the bottom space to the superview.
(Editor -> Pin -> Bottom Space to Superview)
It has an Equal relationship. Constant is 60, Standard is NO, Priority is 1000, and Placeholder is NO.
In iOS 7 it works exactly as expected. In iOS 6, it does not. The bar is not a consistent distance from the bottom when I switch between that view controller and its neighbors, and the buttons frequently do not work (they don't even highlight when I tap them). This is all in the simulator, I haven't tried hardware yet. The app is a legacy app, so all of the layout work is in xib files, not storyboards.
Do I need to do something different in iOS 6 to get Auto Layout to work? From what I read, it should be fully compatible with 6 & 7.
Some more information is needed to really get to the heart of the matter. Specifically how auto layout is being used to attach the bar to the bottom.
One thing that gets me over and over though, is remembering to set the translatesAutoResizingMasksIntoConstraints property to false on view(s) that utilize constraints.
Be sure to check the log output while debugging as that will indicate if you have any ambiguous or unsatisfiable constraints. At design time, XCode 4 IB will attempt to add any constraints that you are missing for you. XCode 5 IB will only tell you what you are missing and then at runtime try to add any missing constraints if it can.