Results 1 to 5 of 5
  1. #1
    Strategies for Orientation/Repositioning

    Member Since
    Apr 15, 2012
    Posts
    5
    Strategies for Orientation/Repositioning
    With the code working, it's time to get the interface looking nice in all orientations.

    Does anyone have any general advice about which way to go - and which ways not to go?

    I'm assuming at the moment that I'm best putting groups of elements into views and that those views then have methods to reposition themselves when rotated? Or do superviews reposition their subviews?

    Thanks.

  2. #2
    Strategies for Orientation/Repositioning
    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    Location
    West Sussex, UK
    Posts
    180
    You can reposition all of your views and sub views with code, but you have to provide all of
    the CGPoints and X and Y coordinates for the different orientations, so the easiest way is to
    let the iOS systems autorotation method handle things for you.

    And yes, the super view will automatically rotate its sub views, in the autorotation method
    provided.

    I recently posted the correct implementation of this method in another forum post, but I have
    posted it again below.

    Code:
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)io
    {
        return (io == UIInterfaceOrientationPortrait || UIInterfaceOrientationIsLandscape(io);
    }
    The above code should be in the super view's controller class, and this implementation of
    the method, will allow for any portrait, or landscape orientation, but you can change this
    methods code to only support certain orientations if you wanted.

    You did'nt say wether you where coding for the iPhone or iPad, as you should also be
    aware, that there are some types of view controller that are device specific, for example the
    UISplitViewController class, will only operate on the iPad, so check the documentation to
    see if the type of view controller class's you are using, are universal to both devices.

    Hope this is of some help.

    Regards Mark

  3. #3
    Strategies for Orientation/Repositioning

    Member Since
    Apr 15, 2012
    Posts
    5
    Thanks Mark. I'm okay with the orientation itself (so far, anyway) but I'm looking for a sensible way to reposition the control elements - recentering being the most frequent need. This applies to both iPad and iPhone of course.

    Is there some kind of

    [myButton whereAmIinTheWindow]

    or

    [myButton.super whereIsMyButtonInTheWindow]

    call I can make?

  4. #4
    Strategies for Orientation/Repositioning
    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    Location
    West Sussex, UK
    Posts
    180
    The UIButton class is a sub class of UIView, so any methods or properties of UIView can
    be called on a UIButton, that includes all of the CGPoint CGRect and Bounds properties, I
    believe from memory that the UIView class has frame and center properties, which gets
    and sets the view's position within its super view.

    So those UIView properties and methods are the nearest thing to a where am i
    implementation for a UIButton object.

    So read the docs on the UIView class, and you can use any of the methods on all of the
    other UI controls.

    Regards Mark

  5. #5
    Strategies for Orientation/Repositioning

    Member Since
    Apr 15, 2012
    Posts
    5
    Ah, that sounds like what I'm looking for. I'll bury my head in that as soon as I can.
    Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. rMBP + Cinema Dispaly 24' - desktop icons repositioning
    By booree in forum Apple Notebooks
    Replies: 2
    Last Post: 06-14-2013, 03:42 AM
  2. Pages '09 page orientation
    By bettyg in forum OS X - Operating System
    Replies: 1
    Last Post: 12-04-2012, 11:58 AM
  3. moving or repositioning an iMac
    By kevn in forum Apple Desktops
    Replies: 2
    Last Post: 11-24-2010, 09:14 AM
  4. Replies: 8
    Last Post: 12-24-2008, 11:45 PM
  5. Monitor Orientation
    By jdgti in forum OS X - Operating System
    Replies: 4
    Last Post: 10-04-2006, 06:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •