Resize app automatically depending on screen size in swift - swift

I just started making an app, and I have done a lot but I was not working with auto-layout. My whole app is in landscape mode, and I want it to work on all iPhone's. I now designed it for the iPhone 5, but when I open it on iPhone 6, there is a lot of whitespace. Is there a button to automatically resize everything? Or must I add auto layout and do every designing bit again?

Unfortunately you're probably going to have to layout everything again with auto-layout. A way to expedite your process would be converting the storyboard to auto-layout and then selecting "Reset to Suggested Constraints". You can access this option by pressing the small triangle icon in the bottom left.
Despite this, you probably will need to update a lot of the constraints manually. But this should give you a step in the right direction.

Have you tried Size Classes? Or Stack Views?
Size classes:
Apple documentation # https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/Size-ClassSpecificLayout.html
Apple documentation on Stack Views #
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/LayoutUsingStackViews.html#//apple_ref/doc/uid/TP40010853-CH11-SW1
A good tutorial on "Stack Views":
https://www.raywenderlich.com/114552/uistackview-tutorial-introducing-stack-views

Related

Xcode 11 Safe Area Does Not Go FullScreen

Since I am using Xcode 11 I am having problems with the Safe Area. My App is an ArKit- App that uses an ARSCNView. after upgrading to Xcode 11 the safe Are doesn't allow me to display it full screen anymore. Actually all the views in all ViewControllers can't be displayed in full screen. I really don't know where to start. Did anyone experience this kind of behavior?
Thanks!
Edit:
I unchecked all the necessary boxes I hope. The behavior I still get is this:
Storyboard Main
Inspector
Live View
There seems to be a view underneath. But I never added one and the inspector doesn't show. This changed with xcode11.
I just found out what happened to my ViewControllers. I am checking for internet connection with a LaunchViewController. The segue from this controller to the next one did not specify "full screen". I still don't know why I have to explicitly tell the segue to do so in Xcode 11. But in the end that solved my problem.
Thank you
The Safe Area is used as a reference for constraints for views and objects that you want the user to be able to interact with. It is used as a guide during the layout of objects on the screen. If you want to take advantage of the entire screen, constrain your views to the superview (basically the main view of the view controller). This is handy for displaying things like backgrounds on the entire view. Take a look at Apple's human interface guidelines for more info:
Apple's Human Interface Guidelines: Adaptivity and Layout
Similar Question:
iPhone X - Safe Area does not achieve full-screen experience?

Designing app for each screen size manually

I'm not very good with Constraints, so basically, my idea is to place all the objects on the View Controller manually for every screen size (iPhone 4, 5, 6, iPad, etc).
Is it possible?
Can I place all of them in one View Controller, or will I have to create a new View Controller for each screen size?
It is possible and you can do it in a single ViewController for each screen size. In Interface Builder if you open a ViewController or any other UI element, on the Attributes Inspector you can see small + signs next to most properties, using which you can add screen size specific properties. Using this approach you can manually create different sizings/font sizes/label texts, etc. for each screen size.
However, I would really recommend learning how to use Autolayout. It is one of the most powerful features of iOSs UI design and working on a large project with a complex UI you will pretty soon regret not learning how to use it. In the long-term it definitely saves you a lot of time and effort. With all the different screen sizes Apple has introduced in the past years, handling them manually is a real pain.

Best way to set up a 4x4 grid of buttons in swift 3

This is my first time working in and with xCode. I am coding a drum pad but am struggling with the User Interface.
Right now i have two views each containing a 4x4 button grid. The first one is for "triggering" the audio samples once a button is pressed. The second one contains a set of toggle buttons used to control a step sequencer.
The app itself is working fine. But im not sure how to build the interface in 'good fashion' So far I have used Interface Builder to create the grid.. set up the constrains manually so that the pads adapt to the device width, and stretch evenly across the screen.
The thing that makes me insecure is how laggy the interface builder runs since i have created these constrains.. might this also affect App performance and launch time?
So i looked up ways to create the grid programmaticaly and came across UICollectionViewwith its reusable cells it seems to fit my use case.. but it also seems a bit like overdoing it.
Its for school, due date is coming closer and somehow i am stuck since days at this point. So could someone please point me in the right direction... how would a modern ios developer set up this grid.
thank you very much
You can use Stack View for the solving of this issue.It could be filled by buttons programmatically or just from storyboard.
This is example form the storyboard.
And this how it is looks at the emulator.

How can I make a grid similar to iphone/ipads launcher screen?

I have seen a few grids made with UITableView but I don't really like how close together each cell is to the other. If there is a way of creating a grid system like the home screen on an iphone (the screen after it is unlocked) if would be great. I don't need an exact solution but a point in the right direction, maybe a set of libraries to look through would be great. I am running xcode 4.4.1
Thanks!
The key is UIScrollView has a paging mode (since could have more buttons than fit in the view). It's covered here's in Apple ocs:
http://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/UIScrollView_pg/ScrollViewPagingMode/ScrollViewPagingMode.html
If you use that, each 'page' would have n buttons/views that when clicked would call a protocol/delegate call back for the consumer with the data to handle and it would evenly layout the UIView/buttons across that page view. Contact me if you want my sample.
You probably don't want to require iOS6 as a minimum requirement but if you do, you can do as H2CO3 suggested in the comment and us UICollectionview. Here's a tutorial: http://www.raywenderlich.com/22324/beginning-uicollectionview-in-ios-6-part-12
There's also some open source launchers that you can look into their code. Here's some (I'm sure there's more).
http://www.cocoacontrols.com/platforms/ios/controls/sespringboard
Code is at: https://github.com/sarperdag/SESpringBoard
Also: http://www.cocoacontrols.com/platforms/ios/controls/openspringboard
Use UICollectionView. You can create grid type views using that. It is available in iOS 6.
If you can target iOS 6+, use UICollectionView. It's one of the best new things in iOS for years and it will be as important as UITableView.
The layout you're asking for is only a few lines of code.
NSHipster has a good explanation of UICollectionViews and Ray Wenderlich has a good tutorial.
(There's lots of example code out there, but here's a very simple example project I did recently for another question involving UICollectionViews)

Creating a tableview in the form of a 'film strip'

I am developing an RSS-reader-type application. I am toying with the possibility of using a normal TableView application but showing the articles as a film-strip. I am mainly thinking for an iPad application (but possible it works on the smaller iPhone as well).
The idea is to have the cells passing/scrolling across the screen using swipe touches (but horizontal, and not vertical as with the normal TableView). They will be some-kind of miniatures of the full article, and when tapped (or with multi-touch zoom to have better control) can be enlarged to read. Then can then just be be moved on as soon as the user has seen enough of it.
Does anybody know if there is an easy way of accomplishing something like that?
The most obvious solution that springs to mind would be to use a UIScrollView, as this will provide the inertial effects, etc. for free - all you'd have to do it populate it with the relevant sub-views. (UITableView's actually use a UIScrollView.)
For more information and sample code, see Apple's UIScrollView docs.
If you want horizontal scrolling, take a look at Jeremy Tregunna’s JScrollingRow. It’s open source under a public domain licence.