How to adjust project layout for multiple phones using auto-layout? - xcode

I have finalized my project and my mistake was that I left auto-layout to be done at the end, now I'm stucked in it and can't find anyway through to finalize my project.
My project layout was made based on Iphone 7 plus "xcode 8" and has 7 viewcontrollers. when I try to put constraints, the whole project collapse.
Anyone can support with any best practice that can help ?

It doesn't matter what device size you are viewing in xcode. Its default for all size classes. If you want to make different layout for specific size class than you use variations. Check this tutorial https://makeapppie.com/2016/09/05/an-introduction-to-size-classes-for-xcode-8/

Related

"Auto Layout before OS X 10.7"

I have an app in the app store, FractalWorks, which is based on a very old code-base. It's a big app, with quite a few screens. It was created in Objective-C before auto-synthesized properties were a thing, to give you an idea of how long ago it was created.
I wrote the app when I had a full-time gig as an independent software developer. I've since taken a day job, and support my apps in my spare time.
It still sells fairly well, and I recently used to add a section to the Wikipedia article on the Mandelbrot set on 3D images: https://en.wikipedia.org/wiki/Mandelbrot_set#3D_images_of_Mandelbrot_and_Julia_sets
I'm fluent in Auto-Layout now, but haven't taken the time to update the app's XIB files from "struts and springs" style to Auto-Layout - nor do I want to invest the time to do so if I can possibly help it.
I want to add a minor enhancement to the app that involves adding some UI elements and making one of the windows slightly taller. The minute I try to use Interface Builder to edit my XIB, it apparently silently changes it to Auto-Layout, and then complains about "Auto Layout before OS X 10.7". (It was released to the app store for OS X version 10.4, if memory serves, and I've moved the OS version up to the lowest version I could get away with in order to support legacy customers. It currently supports ≥10.6. The original, pre app-store version used even older OS versions.)
Googling this error suggests I use the file inspector on my XIB file to un-check a "Use AutoLayout" checkbox, but I don't see any such checkbox.
What am I missing?
If I use Xcode's code review button to compare the XIB file before and after editing it, various "tool version" values are changed, as well as it gaining a setting useAutolayout="YES". Editing that to read useAutolayout="NO" does not solve the problem.
All the credit goes to matt and his comment.
1. In the Navigator (left panel) go to issue navigator and click on the error.
2. In the Inspectors panel (right panel) the Size inspector will be automatically selected. Switch Layout from Automatic to Translates Mask Into Constraints.
Update: It's called Autoresizing Mask now.
3. Repeat for every occurrence of this error.
You may end up with an error not in the Illegal Configuration group like the following which opens the All Messages view in the middle and doesn't open the Size inspector.
This is a compile time error, just build/run your app again.
And also from the previously mentioned comment:
Be careful not to make any constraints, as that will cause an incoherent situation.
If you have multiple auto layout errors, which in all likelihood you will have, select all the controls in a window and perform the operation once rather than for each individual control. Repeat for each window.

How to make my app suitable for all iPhone sizes without using Auto-Layout?

I was using auto-layout and since I was having too much trouble using it I have disabled it. What do I need to make an app that is suitable for all iPhone sizes?
You can add missing constraints at Resolve auto-layout issues. Before that you should adjust the wAny and hAny to base values to for all layouts.
You can't, you must use autolayout - unless you want to write your own layout engine or resort to changing your code every time a new phone screen size comes out.

When I build my app my simulator looks different from my viewcontroller.xib

I was making a user interface using storyboards and when I built my app to see how it would look in the iOS simulator it didn't look like the viewcontroller in the storyboard (some of the buttons were moved around and I had to move one button way down so it was in the place i wanted it to be). Does anyone know why this is?
Yes, the reason is auto layout, it will automatically position elements on a relative basis depending on the device you're running.
You can turn autolayout off, or build for all devices at once and keep it on.
You may want to read iOS Auto Layout Demystified by Erica Sadun which goes in depth to the world of autolayout.

Tell Xcode to not use autolayout on project

Can I tell Xcode 4 that I do not use autolayout in a project?
At the moment, autolayout is on for every new xib created, which means I have to turn it off manually after creating one, and I don't want that.
That's a problem with Auto Layout. You can't set it off in the entire code. You need to get it, as G.H. made.
Right now it's not perfect, but I suggest you to start taking a look at the documentation. I also suggest you to watch the WWDC 2012 sessions videos, that cover this really great feature.

Xcode 4.2: What is the most effective method switching views?

I was thinking of games in particular, where there may be alot of views that need to be switched in and out. Could someone supply some sample xcode 4.2 code? Many tutorials have old xcode versions which have different initial code.
Thanks
Most efficient method I would say is usin the story board feature. Set up a new view controller inside the main storyboard file and then control drag from which red button on one view to the next one. Very easy and no code required. Email me if you had any problems dai.evans94#live.co.uk

Resources