Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is my solution code !This method can add to NSObject class's Categroy , or you can define a Top custom UIViewController class , and let all of your other UIViewControllers to inherit it .</p> <pre><code>-(CGRect)currentScreenBoundsDependOnOrientation { CGRect screenBounds = [UIScreen mainScreen].bounds ; CGFloat width = CGRectGetWidth(screenBounds) ; CGFloat height = CGRectGetHeight(screenBounds) ; UIInterfaceOrientation interfaceOrientation = [UIApplication sharedApplication].statusBarOrientation; if(UIInterfaceOrientationIsPortrait(interfaceOrientation)){ screenBounds.size = CGSizeMake(width, height); }else if(UIInterfaceOrientationIsLandscape(interfaceOrientation)){ screenBounds.size = CGSizeMake(height, width); } return screenBounds ; } </code></pre> <p><strong>Note</strong>, after IOS8 , as <a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScreen_Class/index.html#//apple_ref/occ/instp/UIScreen/bounds">Apple Document of UIScreen's bounds property</a> says : </p> <blockquote> <p><strong>Discussion</strong></p> <p>This rectangle is specified in the current coordinate space, which takes into account any interface rotations in effect for the device. Therefore, the value of this property may change when the device rotates between portrait and landscape orientations.</p> </blockquote> <p>so for the consideration of compatibility , we should detect the IOS version and make the change as below:</p> <pre><code>#define IsIOS8 (NSFoundationVersionNumber &gt; NSFoundationVersionNumber_iOS_7_1) -(CGRect)currentScreenBoundsDependOnOrientation { CGRect screenBounds = [UIScreen mainScreen].bounds ; if(IsIOS8){ return screenBounds ; } CGFloat width = CGRectGetWidth(screenBounds) ; CGFloat height = CGRectGetHeight(screenBounds) ; UIInterfaceOrientation interfaceOrientation = [UIApplication sharedApplication].statusBarOrientation; if(UIInterfaceOrientationIsPortrait(interfaceOrientation)){ screenBounds.size = CGSizeMake(width, height); }else if(UIInterfaceOrientationIsLandscape(interfaceOrientation)){ screenBounds.size = CGSizeMake(height, width); } return screenBounds ; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload