iOS 13 statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window 錯誤


突然的崩潰讓我措手不及

*** 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.'

 

修改方式

  if (@available(iOS 13.0, *)) {

                 // iOS 13  棄用keyWindow屬性  從所有windowl數組中取

           UIView *statusBar = [[UIView alloc]initWithFrame:[UIApplication     sharedApplication].keyWindow.windowScene.statusBarManager.statusBarFrame] ;

statusBar.backgroundColor =UIColorFromHex(0x3757d8);

[[UIApplication sharedApplication].keyWindow addSubview:statusBar];   

 

}else{

 

   UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];

               if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {

                   statusBar.backgroundColor = UIColorFromHex(0x3757d8);

               }

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM