Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I'm trying to do something kinda of basic, but the Xcode has changed its constraint mechanism for size classes, apparently.
And so I want to know how to make this constraint actually apply for all size classes.
iPhone 7
iPhone SE
Please check out these images with constraints and set your lay out accordingly.
It appears I just used a bad previously programmed view controller, I have created a new one, added the subviews and constrains, and everything works fine now.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm making a simple iOS app in xcode using Swift and while I have the entire backend figured out (and it works perfectly), I don't understand constraints AT ALL. I'm trying to make my layout adaptive so it works on all iphone screens but I'm having a really difficult time. Any suggestions on how I can create the perfect layout? Resources would be helpful too. Most resources don't explain the concept or start from scratch.
Another issue I'm having is that every time I click on something, e.g. a table cell, and uncheck "Constrain to margins" and set the constraints, the changes aren't saved and as soon as I hit enter they revert back to the original settings.
REALLY lost on this whole constraints thing. Thanks!
So for learning constraints, I would advice you to do this tutorial. It is lengthy but it covers a lot of important concepts.
www.raywenderlich.com/115440/auto-layout-tutorial-in-ios-9-part-1-getting-started-2
As for constraint to margins, you need to deselect "constraint to margins" before you edit the values. And once you edit a value, make sure the red lines are activated, and do not click on add constraints until you are sure of all the values. (1)
(Image 1)
You can check and edit the constraint in this window, just select your view and go here (2)
(image 2)
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I am learning to program in XCode 7 and Swift 2. I built my app in Main.storyboard, but when I run it in the simulator it looks completely different.
Here are the photos so you can see what I am talking about.
Main.storyboard: http://shrani.si/f/3y/12M/34bm1y0G/1.jpg
Simulator: http://shrani.si/f/1t/ZZ/2AklkVvt/2.jpg
What do I need to do to make it appear the same as in the Main.storyboard?
Thank you for any help,
Aleks
You need to set Constraints.
The easiest way to do it is clicking the triangle and then "Add Missing Constraints" or "Reset to Suggested Constraints" (All Views in XYZ)
It takes a bunch of time to really understand how constraints and auto layout is working. And Xcode helped me a lot with the suggested constraints...
Here is a good tutorial for the start:
http://www.raywenderlich.com/115440/auto-layout-tutorial-in-ios-9-part-1-getting-started-2
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have an app made for a iPhone 5 screen and am having trouble making it so that it will look the same on a iPhone 4. I can't seem to figure out how to use both screen sizes without making 2 storyboards because there are about 35 views. Any answer that may help me fix this problem will be greatly appreciated.
Sincerely, Nick
~Beginner at IOS Development
Create the views more dynamic. For instance does a tableview fill up the extra space with rows. Autolayout can help increasing the distance between UIElements for this.
The old (iOS 6) way to disable iPhone 5 was not to submit the iPhone 5 Splashcreen. Afaik this "trick" isnt working anymore.
Best have a look on xcode 5. It can switch the storyboard from 4"to 3.5"on the fly and respects autolayout. Consider it as a great opportunity to get used to autolayout. (You will need it in the next gen of devices it seems)
Edit:
Make sure the top most view does resizing and this resize is passed down to your table/collectionview
If you use Autolayout then just pin the 4 borders of the collection view,
If you dont use autolayout, refer to picture 2 and make sure the autosizing behaves the same. Either way will work.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I should create an app compatible with the screen sizes of the iPhones 4 and 5. On the web I found some ways to organize my project. The best ways to do it are to:
create two storyboards,call one when screen size is 568 and the other when screen size is 480
use autolayout and have an unique storyboard
I don't know how to use autolayout and I should learn its implementation in my project.
Then in this situation, I want to know by your experience what's the best approach.
I think that first approach is very intricate and slow, with two storyboards you can make mistakes and don't have the same situation in each device.
In my experience I used xib files, and I used two xib file for each viewcontroller, a solution which is very very noisy.
Then, what can you tell me about these approaches?
AutoLayout will make it easier to adjust your UI for both screen size, but even with the old UIViewAutoresizing you will be able to get everything working.
I would suggest that you do not use 2 storyboards or NIB for that mater, because if a some point an other screen size is introduced you need to create a third storyboard/NIBs.
You can even use the UIViewAutoresizing in NIB and in code.
Just set the autoresizing mask correct to grow/shrink with the screen size and you will be good to go.
Well , if you want to make app that run on both iOS 7 and iOS 6, than its better to use Autolayout, because it is easy to use, and also too much flexible.
Because your other options are too much complex and time consuming as well.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Yesterday, I have a problem with CGRectMake, which I already posted here: CGRectMake is not working with UIView
It is caused by having Auto Layout enabled in my project, so I have disabled it. Case closed...but today, when I run my project on the 3.5 inch simulator I have a new problem - all of my textfield, buttons, etc. seems like a mess.
Everything has no proper space between them, unlike when I had Auto Layout enabled. Here's what it looks like:
Is this the consequences of not enabling Auto Layout? If so, what should I do to make constant space between textfield, space of label to navbar, etc?
There is nothing i haven't been able to accomplish using autolayout. In my opinion if you don't use it you will go crazy.
I think the root of your problem is that in the question that suggested you disable autolayout it could have been fixed another way: Add any view manipulating code (resizing, etc) in viewDidLayoutSubviews in your view controller.