[Help] iPhone View Swap (on Orientation Change)

Discussion in 'iOS Development' started by cocotutch, Feb 12, 2009.

  1. cocotutch

    cocotutch Community Development Team Staff Member

    Joined:
    Oct 6, 2008
    Messages:
    1,285
    Likes Received:
    117
    Device:
    5G iPod touch
    Hiya,

    I have implemented code to have my iPhone switch views on device rotation.

    However, I build my app for the Simulator, and instead of the new view rotating/adjusting to the device rotation, the view stretches, but remains in a weird position.

    Example:

    Picture 1.png

    The view "landscapeView", stretches to landscape, but when I rotate the device, it remains in the above position.

    Picture 2.png

    And this is what my app looks like on launch.

    Picture 3.png

    And the view above is my second landscape view, this one appears when my device is rotated to LandscapeRight, the other appears when device is rotated to LandscapeLeft.

    Any help?

    cocotutch
  2. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    set the UIView's autoresizingMask to whatever you need for it to resize right.
  3. cocotutch

    cocotutch Community Development Team Staff Member

    Joined:
    Oct 6, 2008
    Messages:
    1,285
    Likes Received:
    117
    Device:
    5G iPod touch
    Hiya,

    I am very sorry, but I have no idea how to do that

    Please Register or Log in to view images

    . At the moment, I am handling the view rotation with a UIView Animation to commit a "degreesToRadians" CGAffineTransformRotate and have the view rotate with a graceful arc and fit the device orientation properly.

    Picture 4.png

    The above image is after I rotate from the "beginningView" to the "landscapeView" which is my Timetable. But the first time I rotate back to the Portrait Orientation, I get this:

    Picture 5.png

    And if I go back to the Timetable for whatever reason, I will eventually need to return to the Portrait View since that is going to house buttons and have a number of functions which I shall implement later. Upon returning to the Portrait Orientation for the second time, this happens:

    Picture 6.png

    The View "autoResizingMask", which I have no idea how to do, will this allow the view to rotate to the Device Orientation without my UIView Animations? These are lagging my app and I get those ridiculous issues.

    Truly stumped here, I have tried the autoResizingMask, and the code I found, both on a tutorial and the Documentation is too complicated for me to use. Is this method a Boolean? If so, do I just type "landscapeView.autoResizingMask = YES" or something like that?

    Thanks,

    cocotutch
  4. cocotutch

    cocotutch Community Development Team Staff Member

    Joined:
    Oct 6, 2008
    Messages:
    1,285
    Likes Received:
    117
    Device:
    5G iPod touch
    Anyone?

    If the UIView Auto Resizing Mask automatically rotates the view to Device Orientation and stretches the view accordingly, could I have a tutorial/code sample?

    Thanks,
  5. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    Use the documentation.

    Code:
    YOURVIEW.autoresizingMask = [UIViewAutoResizingMask
  6. cocotutch

    cocotutch Community Development Team Staff Member

    Joined:
    Oct 6, 2008
    Messages:
    1,285
    Likes Received:
    117
    Device:
    5G iPod touch
    So, I have "landscapeView.autoresizingmask [UIAutoResizingMask", what do I put on the end, my Documentation gives me "@property" stuff with none of that sample?

    Thanx
  7. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    You really need to learn to use the documentation, not just copy and paste.

    P.S. esc for auto-complete.
  8. cocotutch

    cocotutch Community Development Team Staff Member

    Joined:
    Oct 6, 2008
    Messages:
    1,285
    Likes Received:
    117
    Device:
    5G iPod touch
    theres nothing when I press Esc on my KB, it says "no completions found".

    I have tried declaring the @property in the Documentation by including the property in my ViewControllerH file, and Synthing it in the M, I then get 3 errors.

    Confused.
  9. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
  10. cocotutch

    cocotutch Community Development Team Staff Member

    Joined:
    Oct 6, 2008
    Messages:
    1,285
    Likes Received:
    117
    Device:
    5G iPod touch
    Still haven't managed to find it. I have searched through the Docs many times to no avail. All I find is an "@property" line and if I enter that tidbit of code that you so-oh-nicely gave the first time, I get "no autocompletions found" i also get several compile errors whenever it happens. But, I have now switched to another project with several UIAnimations which handle the rotation of things properly without Orientation of Device being involved. I kind of wanted the Mobile Music Player "Now Playing" to "Cover Flow" Transition.

    Anyway,

    I havent given up, just I am on another project and I will be willing to work on the old one again if I can manage to understand (let alone find) the code I need to complete my Project.

    cocotutch
    ------------------double post merged------------------
    OHHHH, massive correction. That video DID help, I managed to download it here in Oz in less than 2 hours

    Please Register or Log in to view images

    tx
    ------------------double post merged------------------
    But the UIView stretches for me, but doesn't rotate, nvmind

Share This Page