Now, before all you angry people say "hOLY DUCK THIS IS A DUPLICATE", just wait. I've seen at least 10 articles on this, NONE of which have been a help. My issue is im trying to make my iPhone app (xcode 8, swift 3.1, iOS 9 deployment)
match all screen sizes and set the app size to the NATIVE screen size on the device. I've seen the launchscreen articles, and they have been no help because they aren't specific. If somebody could either provide a tutorial or link one so I can figure this out, that would be great. Thanks all
You want to set the constraints for your views.
Here's a tutorial specifically for XCode 8:
https://www.appcoda.com/auto-layout-guide/
Here's another for Adaptive Layouts:
https://www.raywenderlich.com/113768/adaptive-layout-tutorial-in-ios-9-getting-started
At their most basic, constraints lock parts of the view to known areas (top, bottom, left, right) on the screen. Compounding constraints can be helpful for specific problems, but they get complicated quickly. If you're having problems getting them to work properly, I have found it works best to remove all of the constraints and start again with something simple and increase complexity as needed.
Related
I am new to iOS platform but still been able to build my first app in the last 3 weeks. Coming from android, I was able to leverage of some of the knowledge I had to adapt quickly to swift and iOS but I struggle with auto-layout in the storyboard. I have not been able to get a flow that works.
I am currently using Xcode 11 and have tried to UIScrollView but to no uniformity. Whatever I arrange correctly on iPhone 11 deforms on iPhone 8 or lower.
I have watched different tutorials on youtube, lynda.com and pluralsight but to no avail.
What is the best possible way to use auto-layout across different screens like we have in android with constraint layout/relative layout?
I recommend using anchor constrains programmatically. Setting border relative to different items will provide autolayout in all devices. If you post a screenshot of your needs , it might be easier to provide accurate answer. Also keep in mind that superview borders in iphone 8 and lower version differ from borders in higher version according to the top notches. You need to set your views relative to safe area of the superview.
I've been facing an weird issue which I have never experienced before (pretty new to iOS). I am trying to develop a blog reader app and I am using a UITableView inside my main View. Within the TableView I have added 1 prototype cell and modified it's height to be somewhat bigger.
In order to create a "floating", "shadow" or "card" effect within the TableViewVell I have added another View which will contain a cover image and a summary.
The problem I am facing is related to the layout that is displayed by the Preview Assistant for Storybords.
Even though for iPhone 8 (xCode 9.1) everything looks fine based on the constraints that I have put in place, for iPhone SE and 8 Plus things look weirdly different even though during the simulation things do not really look as described.
I have watched WWDC Videos, YouTube Videos, even some great tutorials but none seem to go beyond the basics and actually cover this issue that I am facing.
Here is a screenshot:
XCode Storyboards Preview
I made a simplified demo ofthe project which can be checked out on GitHub:
https://github.com/sebastiannitu/ConstraintIssues
I would very much appreciated if seomeone would calrify this issue for me once and for all. I am sure it's just me doing something silly but I cannot really waste any more time with this. I've already invested about 2 weeks in trying to figure this out!
Thank you very much for your replies in advance!
It's a mild bug in Xcode, but no big deal. Do this:
Change the device type in the canvas, e.g. to iPhone SE.
Switch away to your code, e.g. ViewController.
Switch back to the storyboard. Notice that the constraints have now fixed themselves in the canvas!
Show the Preview for that device type.
So it's mildly annoying, but it does work. Here's the preview for the iPhone SE:
Here's the preview for the iPhone X:
your constraints setup is fine . problem is with only assistant editor. if you run it in your simulator, View (orange View) will resize currectly.
Here is the screenshot for orange View, when running in iPhone 8s (left) and iPhone 5s.
i am not uploading project, but if you have problem then let me know.
So I've been working on an XCode Project for a while, it's practically done but there's a problem I didn't realize until it was too late. I'm working without Size Classes but with Auto Layout. I have a background image in the back and some buttons and labels over it. When I was setting the constraints for everything it all seemed to be in its place and I tested it various times in the same device size (iphone 5s) with the simulator. Now I decided to test it with the iPhone 6, and everything is wrong and not in the place I want it to be. How do I make labels/text fields/buttons keep the same size in ratio to the device?? How could I adapt things proportionally?? Please help.
I was getting the same issue , But after some R&D found useful solution .
Have a look into given link :Set view controller in ratio for iPhone-6 and 6+
Its very easy process and working for me .
I'm sorry for the bad explanations but I've found the way to do it. Here's the video that explained me how use constraints based on proportions and not on pixels.
https://www.youtube.com/watch?v=Gl6DibzPYa4
(The first 5 minutes is basically it)
So I have an app and I want a very different layout based on size class. And I thought I'd accomplished this today because the storyboard preview showed every device and every size in every orientation doing exactly what it was supposed to do. When I ran this on my device and then the simulator however, the size class seemed not to change as the layout was pretty much the same thing as before. Here is screenshot showing my issue. Please note that the psycho spray painting was done by me not Xcode:
So I was hoping someone could help. In case you're wondering, I did the psycho spray painting to protect some confidential info which I thought was pretty obvious but there you go :)
Thanks for reading and thanks in advance for the help!
EDIT:
Here is a screenshot of all constraints for the two main size classes. The green and blue objects that are blanked out do correspond. So the blue thing up top is the blue thing in the constraints. The green is label and slider of the same part of the app's functionality which I don't want to reveal. For now all I'll say is that it's a music app as you can tell by looking at the photos below.
Okay I found the problem! I forgot to resolve some issues in my Compact width and compact height (aka 3.5,4,and 4.7 inch iPhones in landscape) which forced it to use the previous size class's layout.
Create one app for iphone 4 inch screen in Xcode 6.1.1 develop one page successfully and run properly in iPhone 5s. and run iPhone 6 and 6+. its show the white empty page for iPhone 6 for extra height and width. how can support for all the screen in that same code.help me new for develpoment..
This is a very generic question , it is a big topic at the beginning it might be a pain in the ass but you would be amazed how powerful it is when you master it , i would say that you should read a tutorial , let me suggest the following such as :
AutoLayout tutorial
it would be much useful if you learn the adaptive UI concepts as well it is amazing a link for it would be
Adaptive Layout Tutorial
When dealing with Autolayout keep in mind that a major difference between it and using the frames is that you depend on relations between objects position and each other rather than fixed points , try to minmize usage of constants for alignments and keep it as much as possible relative for each other at the same time make sure that each object has a constraint to calculate its width, height , top and bottom positions