Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Jacksonc

macrumors 6502
Original poster
Dec 1, 2013
381
0
Jony's house
Just learning Xcode. I'm making an iPad calculator. I can't figure out how to make everything fit. When I lay it out in Xcode, it looks really good. I launch the iPad simulator, and it is totally different. How do I fix this?
 

Attachments

  • Screen Shot 2014-10-08 at 10.13.00 PM.png
    Screen Shot 2014-10-08 at 10.13.00 PM.png
    99 KB · Views: 119
  • Screen Shot 2014-10-08 at 10.12.56 PM.png
    Screen Shot 2014-10-08 at 10.12.56 PM.png
    69.8 KB · Views: 94
You need to change the view on the inspector panel from implied to iPad. Going from memory but I think implied is the default and it gives you a square view. But you you still need to set up auto layout correctly which would also fix your issue.
 
Without autolayout is a lot easier in my opinion.
Just turn it of, go to measurements of your objects and set the autosizing arrows like you want then to :)
 
@DennisBlah, In order to display this UI on different size screens the sizes of the views must be adjusted. If you're using springs and struts you can only do this by writing code that adjusts the frames of the views to match the screen size. Using auto layout it should be possible to define the relationships that make the views fit onto different size screens without writing any code.

While I agree that auto layout is in some ways harder than springs and struts it's also more capable. And it is the future and the best way to adapt to different size screens.

For a new developer, like OP, it really isn't required to learn springs and struts at all. Start with auto layout and don't look back.
 
@DennisBlah, In order to display this UI on different size screens the sizes of the views must be adjusted. If you're using springs and struts you can only do this by writing code that adjusts the frames of the views to match the screen size. Using auto layout it should be possible to define the relationships that make the views fit onto different size screens without writing any code..

But I never had trouble with different screensizes for iphones or ipads i hardly use any code only for orientation and stuff what i dont like.

With future, you mean you wont be able using autosizing??
 
@DennisBlah, if you generate the calculator screen using springs and struts you'll need code for each view to set its width and origin for different screen sizes, and for both orientations. Not saying it can't be done but it can't be done without code.

When I said 'it's the future' I meant that auto-layout is the future. It's the way Apple wants developers to work now and in the future.

I started a new project a couple months ago. One thing I notice is that there's less code than in older projects. This is in part due to using auto-layout. Less code is good. But, in order for things to work with less code you need a better understanding of how things work in the storyboards and of how things work behind the curtains in many cases. Memory management is different. With ARC you pretty much don't need to think about memory management.
 
@DennisBlah, if you generate the calculator screen using springs and struts you'll need code for each view to set its width and origin for different screen sizes, and for both orientations. Not saying it can't be done but it can't be done without code.

Sorry, maybe I'm misunderstanding this part.
As the screenshot shows, the calculater screen is not generated but its build in the storyboard.

Just as a sample, the result UILabel at the top. When I do this in storyboard, and I use the springs and struts like you call them (I'm not formiliar with these names, I'm kinda newb in xCode), to set top and left and make it scale in width using the autosizing

There is no code involved for setting width or heights. And when I rotate my screen, the label stretches all over the width, also on different devices. It's all related to the self.view as this scales up and down for devices the label will scale itself in width as I only set it's width.

I still must say you do got a point when it comes with multiple views like these buttons... if you set the top and left for all it will fall off screen ;) and also, the buttons won't be stuck to eachother cus the top and left you set, these struts dont scale with the uiview i guess.

I will be going through those links you provided. I been trying around with the autolayout thing with my superior a while ago, but only ended up in warnings and stuff cus we had no idea what we where doing ;D

For now I only used simple views with by code generated buttons to keep the apps dynamicly and scrollviews.
That's why I got myself in this topic cus I want to learn more about this :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.