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)
Related
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.
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.
I am having an issue with running my project on the device. Here are two pictures. The first one shows what the project looks like when I run it on the simulator. The second one is the same project run on the device:
As you can see in the first screenshot, I am using Auto Layout and Size classes. On the attributes Inspector I have the size set to iPhone 4.7-inch, but if I set to to "inferred" the same thing happens. I have done a fair bit of research on the web to see if I can find the solution but to no avail. I am fairly new so it could be something simple. Any help appreciated.
Update: I have set the size to inferred and turned off size classes and auto layout and I had resize all the buttons from 100 pixels to 80 pixels and now it looks fine on the device but I get the opposite problem on the simulator which was fine then. Is this an issue to do with iPhone 6 plus?
See next screenshot. On the left the storyboard and on the right the simulator.
Have you set attribute for it..? Because you are using size class.
Check it. If not set then set it for all objects.
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.
Well, my problem it´s not code related. Almost all visual iOS Applications that i make at xCode got distortions at run time, for example I put a text input at the very center of the Mainboard and the simulator puts it way below than that at execution time. I would attached an image of an example regarding the problem, but I don´t have the reputation. What could the problem be? I´ve already uncheked NSLayout settings
You are creating your views for 4 inch screen and then run Simulator for 3,5 inch screen. No surprise that your positions are different. You should use Autolayout + constraints or UIView:autoresizingMask property to make your GUI change automaticaly for different screens.
Start with this article http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1