UIView on IPhone plus stretched and normal on regular sized iPhone. Constraints are all done in story board. I’m not sure what I’m doing wrong. Please help. Attached are imaged of the views : iPhone 7 Plus and iPhone 7.
I figured my issue was with my misunderstanding of auto layout, which is why I was not able to get my uiview to adjust properly across different screen sizes. This tutorial on youtube really broke down auto layout in such a simple way. Check it out (link below). I hope it helps someone else out there. thanks!
"Auto Layout Tutorial in Xcode with Swift for iOS 11 | iOS Development Tutorial"
Your problem is in the bottom constraint because of different screen heights you get different height for the view as the bottom constraint is static (528) , so to fix that remove that constraint and give it a static height or proportional to screen height
Also remove one of the top constraints as setting 1 is enough
Related
I'm creating a simple app that includes a table view using Swift 5 and Xcode 11. Inside the table view(which, by the way, is fixed into landscape), there is a button on the right of the tableview cells and an image view with fixed constraints, size, and width on the left. Everything has been working out pretty well for my app, until I noticed that the image view would kind of 'disappear' if I changed the device to, for example, iPhone 5s, 4s, or even iPhone Pro(I'm testing with iPhone 11 Pro Max).
This is when the device is iPhone 11 Pro Max:
11 Pro Max
This is when the device is iPhone 11 Pro: 11 Pro
And here are my constraints for my image view: Constraints
Any help is appreciated
P.S. Ignore the image view that says 'img'
After seeing both of the screen shots and the constraints I see what is the issue here.
It's the way you have applied the trailing constraint for the image which in your case is 663 (Should not be fixed). What you can try is Give width constraint to the image view and then change the trailing constraint something like below
This should help you.
Also what you have to take care of moving forward is the constraints you choose to apply coz that is the most important thing while desigining Responsive UI
Happy Coding.
right Constraint should be negative,for example,
img.snp.right = view.right - 20
I have developed my App on XCODE 8 which by default removes iPhone 4 emulator and I didn't notice that until I finished my app, and I used Auto layout to make the UI fits all iPhone screens and that what happened (the layout was good on iPhone 7,6,5) the problem is when I additionally installed iPhone 4 emulator I found that the layout is totally missed up and unreadable/usable.
So what options do I have to solve this and make it fit the iPhone 4 screen too with Auto-Layout with missing up the other sizes ?
Here is screen shot of my Login screen on iPhone 6 (4.7") vs iPhone 4 (3.5")
You must always give constraints with respect to other alternative buttons or a view, it should not be hard coded. Try making views programatically, it will be more easy and helpful to you.
It seems like your constraint is set to have a fixed distance related to the top of your screen. So when the screen height get smaller, your views are pushed out of the screen. So to better adjust views position, you can have your views to be related to vertical center. Say your login box is in both horizontal and vertical center, not metter you are using iphone 6 or 4, you should always see your login box.
So basically I'm designing a layout for my app and I have difficulties adjusting my layout for iPhone 4. For an example look at these screenshots:
As you can see it barely fits on the iPhone 4 and the iPhone 6 has a blank space on the bottom. Am I using Auto Layout incorrect or is this the intended behaviour?
I also struggled not being able to make text fields smaller to fit the iPhone 4 screen in another layout.
Help would be much appreciated!
if you embed all views in a UIScrollView (with autolayout set), your content will be always visible(scrollable)
if you use size classes, you can set a specific UX for iPhone4
I have an app which uses auto layout constraints added in Xcode designer , mostly using "add missing constraints" option from Editor menu , problem is screens looks good on iPhone 6 iOS 8.3 emulator but doesn't work on actual iPhone 6 device iOS 8 as well. I m not adding anything from code
Below are the examples
What am i missing with auto layout ?
**** additional details ***
There is a principle that you need to know.. Every view you add to the storyboard must have enough constraints to confirm it's:
Width
Height
X position
Y position
You should review the constrains you added.
Especially the first textfield(Your Full Name).
Seems like it's Y position constrains wrong.
You will get into problem 9 out of 10 times when Xcode adds missing constraints for you. I would suggest you to go for a better tutorial of autolayout.
With all these different screen sizes in iOS 8, I'm having an Auto Layout dilemma trying to centre this UITextView to display properly on all the different sizes of iPhone.
I've tried using various constraints - but I am still clueless on how to achieve my desired result.
This is where I am without applying any constraints.
As you may be able to see, I'm using a universal storyboard and I am trying to cater for 3.5, 4, 4.7 and 5.5 inch devices.
I recognise that I must apply some sort of constraint or alignment to universally centre the UITextView - my question is what should I do to achieve this?
Ultimately, is there a method that I can employ for my storyboard content to be scaled proportionally on all devices, avoiding this issue of variated alignment on different screen sizes? I'm having a similar problem on my other UIViewControllers, to display UIKitelements in proportion to as seen on the storyboard. Any help would be much appreciated, thanks!