How to resize my app for every iPhone - ios

I'm a beginner app developer and just finished creating my first soundboard app, the only problem is that the layout of the app fits on an iPhone 6s but when i change the simulator to any other iPhone the app doesn't fit on the screen the positioning of it changes and some buttons are left out, how do i make the size of the app fit on every iPhone?

because you did not write code related to layout fitting.
there will be two ways you can auto layout your UI.
firstly,calculate the frame of each UI component and put those code into layOutSubviews.
secondly,using autoLayout is wise choice and I would recommend you Masonry which is a third-party autoLayout framework if you develop under Objective-C.
best regards & thanks

There are several ways to to accomplish this task:-
Auto Sizing, Old way to make UI for different screen size this
will use the struct and spring framework to create UI.
Multiple StoryBoard, You can create a separate storyboard for
different device. Simple but never recommend to use this way as it
will make application more complex and make application heavy, you
have to update every storyboard when ever you have to make changes
in UI
Programmatically, you can also create your UI
programmatically and calculate there frame and set constraint to
your UI
Auto layout "Recommended" , can create a single
storyboard and and apply auto layout constraint to you view on
storyboard and programmatically.
here are some link on auto layout
https://www.raywenderlich.com/115440/auto-layout-tutorial-in-ios-9-part-1-getting-started-2
http://www.appcoda.com/introduction-auto-layout/
https://www.weheartswift.com/auto-layout-101/

You need to use Auto layouts and size classes for this.
Auto layouts:
Auto Layout dynamically calculates the size and position of all the views in your view hierarchy, based on constraints placed on those views. For example, you can constrain a button so that it is horizontally centered with an Image view and so that the button’s top edge always remains 8 points below the image’s bottom. If the image view’s size or position changes, the button’s position automatically adjusts to match.
This constraint-based approach to design allows you to build user interfaces that dynamically respond to both internal and external changes.
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/
Size classes:
Use size classes to enable a storyboard or xib file to work with all available screen sizes. This enables the user interface of your app to work on any iOS device.
With size classes, a storyboard or xib file can be used for any available screen area. You build your interface as it will look in most sizes, then update only the parts that need to change when the available screen size changes.
https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/AboutAdaptiveSizeDesign.html

Related

iOS: Is it possible for UI objects to respect safe area without auto-layout in storyboard?

In my example, I have three buttons at the top of the UIStoryBoard. This works well for non-iphone x devices. However, it gets cut off when I use iPhone x. The buttons go above the safe area.
I was wondering if it is possible for the UIButtons to respect the safe areas without auto layout in storyboard? If not, how do I replicate this layout (UIButtons auto-resizing with flexible width and flexible height) with auto layout and respecting safe areas? I believe I should use aspect ratio on the UIButton's itself. Not sure if this is the proper way.
Turns out the answer is easier than I thought. Just put all the UIButton's inside another view. Then add constraints to that view that respects the safe areas. This way the UIbuttons can still use autoresizing.
Migrating a project using autoresizing masks for iPhone X

Alignment Issue in AutoLayout in IOS Swift

I have 3 sections, Top Banner with Logo, Mapview in the middle and then a few labels under the MapView.
I have used Constraints for accomplishing this for 6s sizes. But when I try this out for 4s, 5, 5s the below section the Labels is not seen on the screen. In design view they are also only partially shown and seems to be somewhere hidden in 4 and 5 ios versions.
I have set height for the Top banner as 0.2 with the SuperView and MapView with 0.4 and trying to get the remaining labels to fill in the remaining 0.4 height of the total SuperView.
I have tried to contain all the labels in a Tableview also this is not even showing anything in Design time or even at runtime.
Another Approach is to Add a view in which place all the labels so that can add a contraint of 0.4 height for the view. But all in vain.
Layout Design :
http://imgur.com/aIjBJsq
I am an iOS and auto layout Noob so it maybe something silly that I might have missed. Appreciate any help or advise on the same
Ok, first it seems that you need a break down of the fundamentals of Auto Layout. Below are some resources that can help you with that. Working with Auto Layout can take quite a bit of effort so you really should get a solid understanding, otherwise you will constantly be running into problems.
Adaptive User Interfaces
Auto Layout Guide
View controllers and adaptivity and size changes
WWDC2012: Auto Layout by Example
WWDC 2015: Mysteries of Auto Layout, Part 1
WWDC 2015: Mysteries of Auto Layout, Part 2
Key to understanding your issues is the role layout constraints play in your design. You use them to make small to medium changes, for bigger changes such as different devices you need to use size classes as well as constraints. In Xcode 8's Interface Builder you have the option to set the device for your layout, see the picture below. It's in the bottom left-hand corner. The device's selection relates to size classes.
So how do we go about solving your issues? We would start by laying out the view for a selected device in interface builder, then we would select another device, say iPhone 4s and then make any adjustments to your view there. This is the basic outline and there are many steps in between. The single best step you can take at this point is to get a better understanding of Interface Builder. Learning how to use interface builder will touch on all the areas covered by the resources listed above.
Interface Builder
wwdc2015: Implementing UI Designs in Interface Builder
I understand this is a broad answer to your question, but I am trying to help you build an understanding of the concepts, so you can happily build your own layouts from here on out!

iOS grid UI control

In XCode Swift Storyboard with auto layout enabled I need to put a row of buttons (let it be 6 buttons) filling screen by width. The buttons must be of the same width, keeping aspect ration the same (so row height will change when screen width changes).
I think that I need to use an UI control like GridLayout in Android, but so far I can't find anything suitable in iOS.
Please advice.
There's nothing in Interface Builder that allows you to do that automatically, that is, without having to position and set constraints for each your buttons yourself. For iOS 9.0, UIStackView might be helpful for you, but until then (and possibly even still) I'd do it programmatically using UICollectionView.

iOS Auto Layout create something similar to responsive design in CSS

Few words about the goal:
I have iPad screen that will be rotated, so it means I will have different width and height during the work app. I have two UIView on the screen. So when the device is in portrait mode the views are located like on image below:
When the device is in the landscape mode:
If the views have subviews I want to stretch them also after parent view will be modified.
Is there any way how to make it using Storyboard and auto layout feature?
You can't change the positioning of your views in the way that you're describing through one set of autolayout constraints. To achieve something like what you're describing, I suggest that you take a look at this question: Alternative iOS layouts for portrait and landscape using just one .xib file. The main solutions described are to use multiple views, multiple interface files, or to swap between two sets of autolayout constraints.

Float layout in interface builder in iOS?

I want add one UIView – which has various number of UILabel objects – to a UIViewController.
How is it possible to set up constrains via auto-layout so, that if rotation occurs, and view width decrease, than height should increase, and labels should fit in like below, as CSS float do it.
Is it possible with interface builder and not programmatically?
UPDATE
Meantime I experimented iOS8 new interface builder feature called Size Classes (WWDC 2014 What's New in Interface Builder from 29:59), as matt has recommended down. But as I see, it supports something different, that I am looking for. Size Classes aim is to put different xibs (iPhone, iPad) into one xib, to have one xib instead of more.
In my case it does not help. What I have done to set up different auto-layout constrains for these two size classes:
But when I was running the application in iPad 4 simulator - what is the main target for my app - it used always the regular width / any height size class, and never the any width / any height, what my original expectation would have.
I do not know what "in a floating way" means. But in Xcode 6 you can easily do what you're describing, changing the constraints in an iPhone app so that the fourth label drops down to the next line, using the new conditional constraints (size classes) feature. With this feature, you can have one set of constraints for one set of size classes (e.g. iPhone in landscape) and another for a different set of size classes (e.g. iPhone in portrait).
Prior to Xcode 6, the answer would be no, you can't do that using IB alone. Code of some sort, whether a collection view or your own code responding to rotation/layout, would have to change the constraints.
With UICollectionView you can set up layout like CSS float.

Resources