【问题标题】:device Orientation to statusBar Orientation changes设备方向到状态栏方向更改
【发布时间】:2025-11-27 03:30:01
【问题描述】:

我创建了一个设备方向监听器来捕捉设备旋转时的情况,就像这样

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(jumpBarButtonPosition)
                                                 name:@"UIDeviceOrientationDidChangeNotification" object:nil];

但是在 jumpBarButtonPosition 方法中,我已从使用 UIDeviceOrientation 更改为 statusBarOrientation,因此我正在考虑可以替换 UIDeviceOrientationDidChangeNotification 的内容,以便仅接收有关 statudBarOrientation 更改的通知。

【问题讨论】:

    标签: iphone ios uideviceorientation nsstatusbar


    【解决方案1】:

    不要将其键入为字符串:@"UIDeviceOrientationDidChangeNotification" 使用:

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(jumpBarButtonPosition)
                                                 name:UIDeviceOrientationDidChangeNotification object:nil];
    

    【讨论】:

    • 好吧..但这看起来不像是检查状态栏方向,我问这个的唯一原因是因为我想忽略 faceUp 和 faceDown 通知..
    • 设备改变状态栏的方向。但是,如果您有另一种方法可以在不改变设备的情况下更改方向,请在该方法中发布通知。
    • 好吧,这一切都很好。我只是希望忽略那些正面朝下的通知,因为它们对于我担心的事情来说是多余的,感谢您的帮助,如果我没有收到任何通知,我会将您的通知标记为正确在接下来的几个小时内会有更多答案。干杯。
    最近更新 更多