答案 0 :(得分:14)
您可以通过两种方式解决此问题
选项1 。在
中尝试此操作private HttpServletRequest request; private static ThreadLocal<WebContext> wcHolder = new ThreadLocal<WebContext>(); private WebContext(){} public static WebContext newInstance(HttpServletRequest request){ //case 1:correct // WebContext wc = new WebContext(); // wc.request = request; //case 2:incorrect //(to resolve multiply creat WebContext object within one request) WebContext wc = wcHolder.get(); if(wc==null){ wc = new WebContext(); wc.request = request; wcHolder.set(wc); } return wc; }
方法
didFinishLaunchingWithOptions
选项2 。覆盖
中的func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { UIApplication.shared.isStatusBarHidden = true return true }
prefersStatusBarHidden
功能
UIViewController
注意:您致电override var prefersStatusBarHidden : Bool {
return true
}
它应为override func prefersStatusBarHidden
答案 1 :(得分:1)
答案 2 :(得分:1)
在视图控制器中覆盖prefersStatusBarHidden
override var prefersStatusBarHidden : Bool {
return true
}
如果状态栏应该隐藏,则为true;如果应显示状态栏,则为false。