应用崩溃并出现错误 +[UIStatusBar frameForStyle:orientation:]: 无法识别的选择器

App crashing with error +[UIStatusBar frameForStyle:orientation:]: unrecognized selector

我正在开发一个用 Xcode 的旧版本制作的应用程序,它目前支持的最低版本是 iOS 7.0

+[UIStatusBar frameForStyle:orientation:]: unrecognized selector sent to instance

我设置了断点,但是找不到问题

UIStatusBar 没有 class 引用,因此您正在对未知 class 调用 class 方法。

你想用状态栏做什么?您可以通过 plist 或通过 UIApplication 编辑它,例如 [[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];

看起来(从 GitHub 上的代码来看)UIStatusBar.h 在某些时候是 UIKit 的一部分。也许这是我们不应该真正访问的私有 class?

伙计们感谢您的回复和兴趣,无意中我开始知道,我已经设置了 UIStatusBar 隐藏,同时有一个 MPVloumeView 添加到视图中,每当我尝试更改音量,它使应用程序崩溃。根据另一个 SO 答案,MPVloumeView 应该在应用程序的第一个 UIWindow 中。

我刚刚在第一个 window 中添加了另一个 MPVloumeView,并使其不可见

MPVolumeView* mpView=[[MPVolumeView alloc]initWithFrame:CGRectMake(0, 0, 1, 1)];
[mpView setTintColor:[UIColor clearColor]];
mpView.alpha=0.01;
{
    NSArray *windows = [UIApplication sharedApplication].windows;
    if (windows.count > 0) {
        [[windows objectAtIndex:0] addSubview:mpView];
    }
}