Simple IOS Layout - ios

I have been trying to do this layout for a few days now and cannot do it. I have no code as I have been only using Storyboard.
In my Android version I simply used a weighted LinearLayout where my title was 20% my relative layout was 60% and my custom object was 20%.
I cannot replicate this in IOS. Everything I try fails. I have tried everything and have tried using StackViews, EqualHeight constraints with multipliers and everything does not work. Most of the time nothing even happens and it just looks the same. Can someone please help me? I am so frustrated I am considering abandoning XCode in total and coding my app in React Native.

It's not really clear what you're asking. But if you want to use storyboards, it's pretty easy with XCode. You can set your layout visually, then simply use the "auto-resolve" feature (little triangle inside of bars on bottom right above the console) to: 1) "clear constraints" and then 2) "reset to suggested constraints". This is a fast and crude method that should more than enough to get started.

Related

Xcode simulates App wrong

I don't know what I've done. Everything was working great until I started styling my app. So, I was working on my main storyboard and when I tried to simulate my App in the simulator. I saw my Icons flying around like crazy.
I am more familiar with coding so I'm sorry if this is a nooby question but I don't know how to describe my problem to Google, I really tried it but it turns out to be other problems.
I will hang on screenshots, one is from my storyboard and the other one is whats the simulator shows me.
View in main storyboard:
View in simulator:
From your description and images, it looks like you're using auto layout but haven't applied enough constraints to locate the images where you want them, or the constraints are just wrong. Take a close look at your storyboard to make sure that you don't have any warnings about missing constraints, and that the constraints do what you want them to do.

How to get iOS app to work on all iPhones? (Constraints)

I am fairly new to developing for iOS. I have a fully functioning program written in Swift and the UI was created in the scene builder on Xcode. I created an app for my work to simplify closing out the registers and other financial aspects. The app is complete and works perfectly, but was designed on the iPhoneX. The problem is that only a few of the employees have an iPhoneX, but they all have some kind of iPhone. I have tried setting up constraints but it never works. Ive tried scaling restraints and position restraints but I can't get the layout to look right on any other phone, and when I add the constraints it affects the view on the iPhoneX as well and doesn't look good on any iPhone. I need help getting this to work on all iPhones. I would like it to look and act the exact same regardless of the size of the phone, basically just scaled down. There are a lot of things on the screen and I can't figure out how to do this. Please help!!!
I have been working on this for a long time and I really need help. Please let me know if I need to clarify anything. I have posted links to some pictures of my UI so you have an idea of whats going on.
Constraints I tried adding, although I have played around with some other options.
Here's what it looks like on the iPhoneX, this is how I want it to look.
What it looks like on iPhoneSE (with constraints).
One thing I noticed in your Xcode project that none of your features are in UIView. Without it, it will be quite challenging and somewhat always different results. In theory, if you use AutoLayout features correctly it should work without UIView, but they make life so much easier. This is something I learned the hard way at the beginning of my iOS development. First set up your UIViews without any content inside it, give them some background colour to differentiate, once they are working on all devices. You can pin your features to superviews with no difficulty.
Since you have a repetitive features, you could also consider using Stack Views. You don't have complicated features, so as long as AutoLayout is set up correctly you should have no problems seeing it ok on all devices

Auto-Layout vertical spacing issue

I'm having some issues with auto-layout where it would show different spacing in IB than in runtime.
Here's the screenshot of IB:
As you can see, the big numbers don't have any padding at the top and bottom.
But when run, it looks like this:
Am I missing something?
BTW, I come from Android dev, and looking at all those constraints I feel like I'm either missing a simpler solution or iOS UI dev is a real pain compared to Android.
"I'm either missing a simpler solution or iOS UI dev is a real pain compared to Android"
You're missing a simpler solution. Auto-layout can be frustrating, until you get the hang of it. After that, it makes things sooooo much easier than it used to be.
Here is a version of your table cell, where the spacing stays consistent between IB and runtime. And, it uses UITableViewAutomaticDimension
As you can see, it's much simpler than what you had. If you tell me if you're using Objective-C or Swift (2.2? 3.0?) Xcode 7 or 8, I'll be happy to make the files available...

Xcode 6: label won't drag

Im just picking up ios development, and Im having a stupidly basic problem with xcode...
I open up a new app and open main.storyboard, and drag in a label to the center of the panel:
It just sticks to the right side, and no matter how many times I click on the darned thing, it won't move! I closed the project and started a new one, and that one worked just fine, but the problem keeps appearing just about every other time I open a new project. why does this keep happening?
That is a strange problem. You say that if you close the project and start it again, it fixes itself but keeps reappearing.
Few suggestions, try clearing up some ram by closing other, unused apps.
If that does not work, I would say delete Xcode, restart your mac, and start over. Maybe something went wrong during the install.
Storyboards are scrollable and when you scrolled out your views, you cannot make any changes to the views. Try scrolling into the storyboard and then retry moving the label.
It's AutoLayout, which is the highly recommended default for laying out components now. You need to create constraints to
position it, using the icons below the layout area.
Some components I've found I need to manipulate via the size inspector, before constraints are applied.
You will need to read up on Auto Layout sooner or later. It may seem like a hassle or drag at first, and a lot of people are cursing when they have to switch to the paradigm, but when you start to master it, it is very powerful. And it really is a sensible way to handle the layout across all the new screen sizes and orientations. It developed out of a need to manage that complexity to keep apps looking good.
Icons in IB where you set constraints for selected views:
Apple has good documentation for how to use Auto Layout as do many bloggers and sites. You will have to put some hours into getting used to it, but in a day or two you should start seeing good results.
(and don't blame me, I'm just the messenger)

Wrong constraints under iOS 6

I am trying to reproduce the parallax effect we can see everywhere nowadays, where, whenever you pull down a scrollview, an image reveals behind it (see this question).
There's a bunch of solutions on the internet, but I'm trying to make it work using auto layout only. I saw someone got it working at a lightning talks a few days ago, but I guess I wasn't paying enough attention...
I got it working under iOS 7, however, under iOS 6, the image view doesn't stick to the top. Here's a sample projet with where I am right now : DCParallaxHeader.
Another question is, is there any way to make the bottom view size's dynamic depending on the screen's size ? (As it it wrapped in a scrollview, and we must provided the contentSize using the constraints too ?).
The person who make the talk wrote a blog post about it. Sums it all :-).

Resources