1

I am using the code below to get screen width and height when device is in landscape.

float widthScreen = [UIScreen mainScreen].bounds.size.width;
float heightScreen = [UIScreen mainScreen].bounds.size.height;

But the problem is in iPhone 4S (iOS7) the width < the height

In iPhone 6 (iOS9): widthScreen 667 heightScreen 375

In iPhone 4S (iOS7): widthScreen 320 heightScreen 480

Does it happened on all iOS7 device or only iPhone4S.
what should I do to fix. Any help would be appreciated

Linh
  • 57,942
  • 23
  • 262
  • 279
  • Have you supplied BrandAsset for iphone 6 and 6s ? – Muhammad Adnan Mar 08 '16 at 04:06
  • When do you initialize these variables? In what method? – rob mayoff Mar 08 '16 at 04:11
  • when launch screen is not provided the screen layout is shrinked man. He will be missing 4.7 and 5.5 inch Brand Assets – Muhammad Adnan Mar 08 '16 at 04:12
  • The apparent screen size is only shrunk on phones that have larger screens than the original iPhone, which means the iPhone 5 and later phones. The iPhone 4S has the same screen size as the original iPhone: 3.5 inch diagonal, and 320x480 points. – rob mayoff Mar 08 '16 at 04:17
  • The complaint is that the screen size is reported differently on an iPhone 4S running iOS 7 than on an iPhone 6 running iOS 9. In both cases, the reported size matches the actual screen size (in points), but the orientation is different. They are not different because of launch assets. They are different because Apple changed what `[UIScreen mainScreen].bounds` returns between iOS 7 and iOS 8. See the link to the already-answered question. – rob mayoff Mar 08 '16 at 04:19
  • ok i got it , thanks for correcting me . – Muhammad Adnan Mar 08 '16 at 04:20

1 Answers1

0

How about [UIDevice currentDevice].orientation ?

I prefer to check landscape by frame in each view instead of [UIDevice currentDevice]. Because landscape in split-view, width can be < height

http://www.cnet.com/how-to/get-to-know-the-ipads-new-split-view-feature-in-ios-9/

- (BOOL)isLandScape {
    return (self.frame.size.width > self.frame.size.height);
}
Tim007
  • 2,557
  • 1
  • 11
  • 20