我正在将 iOS 应用程序从 8 迁移到 XCode9。我不确定是什么原因造成的,但似乎 Swift 3.2/Xcode 9 表现不佳。
所以我正在开发的这个应用程序在所有视图控制器上都有状态栏,但在迁移后它开始只显示主视图。通过选项卡按钮更改视图它变成空白,如下面的屏幕截图。
View controller-based status bar appearance
是NO
和Hide Status Bar
是OFF
我添加setNeedsStatusBarAppearanceUpdate()
了它的参数,但仍然无法正常工作。
这是“另一个视图”的 ViewController 的代码
import UIKit
class InfoViewController: UITableViewController {
private var threads: [Info] = []
private var loading: Bool = false
private var hasNext: Bool = true
private var selectedThread: Info?
private var noInfoView: UIView?
internal var shouldRefresh: Bool = true
private var pagingIndicatorView: UIActivityIndicatorView!
private var timer: Timer?
private var poolingInterval: TimeInterval = 60 * 3
private var shouldClearThread: Bool = false
private var nextViewController: InfoDetailViewController?
let RequireCheckStatusForMessagesNotificationKey = "RequireCheckStatusForMessagesNotificationKey"
deinit {
NotificationCenter.default.removeObserver(self)
stopPooling()
}
override func viewDidLoad() {
super.viewDidLoad()
setNeedsStatusBarAppearanceUpdate()
tableView.contentInset.bottom = 40
pagingIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.gray)
pagingIndicatorView.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 50)
pagingIndicatorView.hidesWhenStopped = true
NotificationCenter.default.addObserver(self, selector: #selector(InfoViewController.requireCheckInfosForMessagesNotificationHandler(notif:)), name: NSNotification.Name(rawValue: RequireCheckStatusForMessagesNotificationKey), object: nil)
}
var statusBarStyle : UIStatusBarStyle = .lightContent
override var preferredStatusBarStyle: UIStatusBarStyle {
get {
return statusBarStyle
}
}
var statusBarStatus : Bool = false
override var prefersStatusBarHidden: Bool {
get {
return statusBarStatus
}
}