How to get screen width after rotate?

Discussion in 'iOS Programming' started by mikezang, Nov 17, 2010.

  1. mikezang macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #1
    I use code as below to get screen width, it is ok in Portrait mode,
    the frame is (0, 0, 768, 1004),
    but when I rotate it to Landscape mode,
    the frame is (0, 0, 748, 1024), I need 1024, but it is not width, but height.

    how can I get correct width inside view?
     
  2. cnstoll, Nov 17, 2010
    Last edited: Nov 17, 2010

    cnstoll macrumors 6502

    Joined:
    Aug 29, 2010
    #2
    CGRect Documentation

    It sounds like you should just flip the "height" and "width" coordinate in landscape orientation. The coordinate system appears to shift in landscape mode.
     
  3. mikezang thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #3
    Why so abnormal?
     
  4. cnstoll macrumors 6502

    Joined:
    Aug 29, 2010
    #4
    It does sort of make sense actually. That way in the two most common orientations (not counting upside down) the origin is always at the same physical corner of the device. It looks like you just have to take that into consideration when using the coordinate system.
     
  5. mikezang thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #5
    I am still in confused, I will read Coordinate system again.
    Anyway, I got what I need follow your suggestion. Thanks a lot.
     
  6. cnstoll macrumors 6502

    Joined:
    Aug 29, 2010
    #6
    This is probably a better explanation, it was linked in another thread.
    View Geometry
     
  7. mikezang thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #7
    Thanks for your link, I had read similar document for iPhone, but I couldn't find why use height for width, is there any info about this topic?
     
  8. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #8
    Most likely the views coordinates have not changed but a transform has been applied so it displays rotated.
     

Share This Page