横向方向但纵向框架值?

Van*_*nel 8 objective-c frame ios

我正在开发一个带有最新SDK的iOS应用程序.

我已将Landscape Right orientation设置为可用的唯一方向,我对viewController视图有疑问.

这是我的代码:

- (void)viewDidLoad
{
    [super viewDidLoad];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(deviceOrientationDidChange:)
                                                 name:UIDeviceOrientationDidChangeNotification
                                               object:nil];
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != AVCaptureVideoOrientationLandscapeRight);
}

- (void)deviceOrientationDidChange:(NSNotification*)notification
{
    UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
    if (orientation == AVCaptureVideoOrientationLandscapeLeft)
        NSLog(@"Orientation: Landscape Left");
    else if (orientation == AVCaptureVideoOrientationLandscapeRight)
        NSLog(@"Orientation: Landscape Right");
    NSLog(@"FRAME: %@", NSStringFromCGRect(self.view.frame));
}
Run Code Online (Sandbox Code Playgroud)

这是我得到的日志:

Orientation: Landscape Right
FRAME: {{0, 0}, {320, 568}}
Orientation: Landscape Right
FRAME: {{0, 0}, {320, 568}}
Run Code Online (Sandbox Code Playgroud)

我的问题是{{0, 0}, {320, 568}}:

为什么我会得到这些价值?

我认为正确的价值观是{{0, 0}, {568, 320}}.

dre*_*wmm 3

我相信框架矩形不会对方向变化做出反应。

编辑:我原来的解决方案对于您的需求来说过于复杂。如果您正确找到当前方向,那么如果您处于横向模式,则只需将矩形的宽度解释为高度。