Nothing fits in window...

Discussion in 'iOS Programming' started by Jacksonc, Oct 8, 2014.

  1. Jacksonc macrumors 6502

    Jacksonc

    Joined:
    Dec 1, 2013
    Location:
    Jony's house
    #1
    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?
     

    Attached Files:

  2. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    Is that Yosemite? Hardly anything looks familiar to me in that screenshot...
     
  3. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #3
    They look pretty much the same to me. What makes you say they look "totally different"?
     
  4. Jacksonc thread starter macrumors 6502

    Jacksonc

    Joined:
    Dec 1, 2013
    Location:
    Jony's house
    #4
    The right edge is cut off, and the bottom as lots of space
     
  5. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    Are you using auto-layout? If so, how are your constraints set up? If not, how are your struts & springs set up?
     
  6. Punkjumper macrumors member

    Joined:
    Jan 12, 2013
    #6
    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.
     
  7. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #7
  8. DennisBlah macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #8
    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 :)
     
  9. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #9
    @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.
     
  10. AxoNeuron macrumors 65816

    AxoNeuron

    Joined:
    Apr 22, 2012
    Location:
    The Left Coast
    #10
    Xcode 6
     
  11. DennisBlah macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #11
    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??
     
  12. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #12
    @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.
     
  13. DennisBlah macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #13
    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 :)
     

Share This Page