Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

creating constraints

hello, I'm currently attempting the calculator app challenge. And I have run into a slight problem. My calculator app has 15 buttons and a label at the very top displaying the value. After watching the constraint tutorial video on the crystal ball project, I decided to make my calculator app visible in the iPhone 4inch and 3inch, however I have been having a little trouble accomplishing this. It was very easy when in the crystal ball tutorial with one button, but 15 buttons and label side by side is giving me some trouble. A guide to the light would be very helpful...

2 Answers

Holger Liesegang
Holger Liesegang
50,595 Points

Hi Marvin, you can put all these buttons into one View as a container and then apply the constraints on this container view.

You might also want to have a look at https://github.com/HolgerLiesegang/calc how this possibly can be accomplished, if you like :)

Kind Regards and good luck with your Calculator App :) Holger

Mr. Liesegang, I was doing some research on your statement you made about putting all the buttons into one view as a container, and then apply constraints on the container view. I came across this information. https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html

My problem is that i'm confused on how I actually connect this all together.

Holger Liesegang
Holger Liesegang
50,595 Points

Hi Marvin,

first of all I didn't mean to annoy you by using your last name in combination with "Hi". I'm just on tour till the weekend at the moment and using Treehouse only for a few moments a day :-)

But to the task at hand: It's really way much simpler as it sounds because with the case of the calculator in your storyboard you really only have to put all the buttons into an other view and then apply the appropriate constraints to this view - so really nothing to code about.

You also might want to have a look at Ben Jakuben's Videos Introducing Auto Layout and Using Auto Layout for Various Screen Sizes