0

Where can I get, programmatically, the current visible View / Window size?

especially relevant when changing orientation.

e.g. for Retina 4, I wish to get:

  • Upon Portrait: 'h = 568.00, w = 320.00'.
  • Upon Landscape: 'h = 320.00, w = 568'.

I've tried several elements and always get the same values (no matter what the orientation is):

[UIScreen mainScreen].bounds.size;
[UIScreen mainScreen].currentMode.size;
[UIApplication sharedApplication].delegate.window.bounds.size;
Ohad Regev
  • 5,641
  • 12
  • 60
  • 84

2 Answers2

2

I use

UIScreen.mainScreen().applicationFrame.size.height

Bassem Tourky
  • 482
  • 5
  • 12
0

try this:

UIDevice * device = [UIDevice currentDevice];
switch(device.orientation)
   {
       case UIDeviceOrientationPortrait:
       /* start special animation */
       break;

       case UIDeviceOrientationPortraitUpsideDown:
       /* start special animation */
       break;

       default:
       break;
   };

see this for more information : Detecting iOS UIDevice orientation

Community
  • 1
  • 1
Dev138
  • 334
  • 1
  • 13
  • Thanks, Dev138, but that wasn't the issue... The issue is VIEW SIZE, i.e. HEIGHT and WIDTH. I'm looking for the property / method / object that holds the VISIBLE SIZE VALUES. – Ohad Regev Sep 04 '14 at 11:27
  • if you know the orientation can't you know if to switch height with width or not ? – Dev138 Sep 04 '14 at 11:29
  • I can... But I was wondering if there's any available variable, anywhere, that simply holds these values. Of course, I can retrieve the DEVICE, SCREEN SIZE and the ORIENTATION and calculate it manually for any given possibility (Retina 3.5 / Retina 4 / iPad / over Portrait / Landscape), but I thought that it might already exist somewhere in Apple's Objects... – Ohad Regev Sep 04 '14 at 11:43