ios – 横向方向但纵向帧值?

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

我已将Landscape右方向设置为可用的唯一方向,我对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));
}

这是我得到的日志:

Orientation: Landscape Right
FRAME: {{0,0},{320,568}}
Orientation: Landscape Right
FRAME: {{0,568}}

我的问题是关于{{0,568}}:

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

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

解决方法

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

编辑:我原来的解决方案过于复杂,无法满足您的需求.如果您正确找到当前方向,那么只要将您的宽度解释为高度(如果您处于横向模式).

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...