4

I have an application that is configured to support Portrait mode only. But I have to show one screen (say abcViewController) in my application in landscape mode. When abcViewController screen is pushed ,orientation changes from Portrait mode to Landscape mode. In that abcViewController screen statusBar, all images ,buttons are shown in landscape mode but UIAlertView is displayed in PortraitMode. This means everything on view changes to landscape mode in abcViewController but UIAlertView doesn’t rotate to Landscape mode and remain in Portrait Mode. I would like the UIAlertView to follow the rules of the containing view controller and show same orientation as statusBar.

enter image description here

Note: I m running my app on iOS 8.0 using Xcode 5.0 and I am searching for the solution which supports Xcode 5.0

4

1 回答 1

3

实际上,我以UIView编程方式为 iOS 7 和更早的 iOS 版本旋转了此类的状态栏,但是我在 iOS 8 中遇到了这个方向问题,然后我阅读了 iOS 8 的一个新变化,它与下面给出的方向有关:

我在 iOS 7 和 iOS 8 中都运行了以下代码:

UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
BOOL landscape = (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight);
NSLog(@"Currently landscape: %@, width: %.2f, height: %.2f", 
      (landscape ? @"Yes" : @"No"), 
      [[UIScreen mainScreen] bounds].size.width, 
      [[UIScreen mainScreen] bounds].size.height);

以下是 iOS 8 的结果:

Currently landscape: No, width: 320.00, height: 568.00
Currently landscape: Yes, width: 568.00, height: 320.00

与 iOS 7 中的结果比较:

Currently landscape: No, width: 320.00, height: 568.00
Currently landscape: Yes, width: 320.00, height: 568.00

所以,我知道 [UIScreen mainScreen].bounds.size 在 iOS8 中变得依赖于方向。

在阅读了 iOS 8 的这个新变化后,我为 iOS 8 创建了一个新类,所以你有两个解决这个问题的方法。

解决方案 1:您应该使用UIAlertController而不是UIAlertView.

解决方案 2:您可以为遇到此方向问题的 iOS 8 创建一个新类。

于 2015-01-06T09:15:42.560 回答