Xcode 7 size class issue? - ios

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.

Related

Center a UIView inside a TableViewCell

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.

Set app size to native iPhone screen size xCode

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.

Icons overlap line items in landscape view

In a mobile app developed by a friend when you are in landscape mode on an iPhone there are icons that overlap text.
I wonder if this is a common problem and if it is obvious to anyone what possible factors could cause this?
See screenshots below:
Regular
Landscape
There has to be an issue in the project with constraints. The text and the icons are not constrained to themselves so when the screen width changes their position changes as well. It looks like the icons are misplaced in the landscape view so I would start looking for the solution in that direction.
This is quite common and thankfully easy to fix mistake. New developers are working with fixed screen sizes and forget that there are multiple sizes to consider. Working with constraints will come along with experience so don't worry.

Auto Layout issue in XCode

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)

Resize Uibutton with Auto Layout & size class

I have developing app for iPhone & iPad. so I choose Auto Layout & Size class its bit complex to understand. I have tried to add number pad with my app Please refer the screenshots.I added iPhone 6, iPhone 4s and iPad screenshot. I want exactly iPhone 6(screen1) output. but I cant get it in iphone 4s(screen2).
in iPad(screen3) atleast need to show those buttons at center of the screen. can any one help on this.
I try to set less or greater then size to buttons but its not working. please suggest me how to make same look on all screens.
In order to achieve the same results for different iPhones and iPads you must actually work with and implement the size classes you chose. Please refer to Apple's manual at: https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/AboutAdaptiveSizeDesign.html
Another great tutorial is at: http://adoptioncurve.net/archives/2014/08/working-with-size-classes-in-interface-builder/
As you mentioned in your question- size classes might be less intuitive. From my experience, reading Apple's manual will help you understand how to accomplish exactly what you need.
I hope this helps.

Resources