douyin-ios-objectc icon indicating copy to clipboard operation
douyin-ios-objectc copied to clipboard

运行直接崩溃

Open QiaoLansheng opened this issue 4 years ago • 3 comments

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'App called -statusBar or -statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window. Use the statusBarManager object on the window scene instead.'

QiaoLansheng avatar Jun 15 '20 12:06 QiaoLansheng

- (UIView *)statusBarUIview{
    if(@available(iOS 13,*)){
        
        int tag = 13004352;
        
        UIWindow *window = [UIApplication sharedApplication].delegate.window;
        UIView *view = [window viewWithTag:tag];
        if (view) {
            return view;
        }else{
            CGRect statusBarRect = [UIApplication sharedApplication].statusBarFrame;
            UIView *statusBarView = [[UIView alloc]initWithFrame:statusBarRect];
            statusBarView.tag = tag;
            [window addSubview:statusBarView];
            return statusBarView;
        }
    
    }else{
        UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
        if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
            return statusBar;
        }
    }
    
    return nil;
}

cnzlh avatar Jul 03 '20 10:07 cnzlh

setStatusBarBackgroundColor 崩溃了= =。。 看了上边代码大概知道问题了= =。。求github上版本更新下

liubang0909 avatar Jul 13 '20 03:07 liubang0909

在BaseViewController中得 setStatusBarBackgroundColor ,将里面的代码注释了即可,原因是iOS13以后,系统会自动调用status bar

AlureLove avatar Aug 24 '21 16:08 AlureLove