-3

I am migrating an iOS app to XCode9 from 8. I'm not sure what's causing but it seems like either Swift 3.2/Xcode 9 is behaving badly.

So this app I'm developing has Status bar on all the view controllers and so has it been, but after migrating this started showing only the home view. Changing view by tab button it becomes blank like the following screenshots.

Home view

Another view

View controller-based status bar appearance is NO and Hide Status Bar is OFF

I added setNeedsStatusBarAppearanceUpdate() and its parameters but still not working.

Here's code of ViewController of "Another View"

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
    }
}
kela
  • 1
  • 1
  • 1
    "but it seems like either Swift 3.2/Xcode 9 is behaving badly" No. _You_ are doing something wrong. But you are not telling us what you are doing, so who knows what it is? If you want help you must be a lot more forthcoming. – matt Nov 16 '17 at 04:07
  • @matt I'm sorry but in code nothing about status bar is written... Can you please tell me what information you need? – kela Nov 16 '17 at 04:13
  • It's very hard to understand the *specific* issue with the "scratch out" areas (along with the `NO/YES` verbiage - that's not Swift - along with the "code dump" and description). So let's try this.... (1) Can you describe either by a better screenshot(s) or verbiage what **exactly** is different between "Swift 3.2/Xcode 9" and... Swift 3.1 and Xcode 8? (2) Can you slim down your code to the point that we could actually duplicate the issue? The obvious point - @matt already said it - is that the *fault* is **not** Swift 3.2 or Xcode 9. If it were, others would be complaining for months. –  Nov 16 '17 at 05:25
  • The status bar is present. Your background is white so you can’t see it. Try a black background. – matt Nov 16 '17 at 14:30

1 Answers1

0

It's easier to have View controller-based status bar appearance set to YES and to play with the following parameters of UIViewController:

override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
    get {
        return .slide
    }
}

var statusBarStyle : UIStatusBarStyle = .default

override var preferredStatusBarStyle: UIStatusBarStyle {
    get {
        return statusBarStyle
    }
}

var statusBarStatus : Bool = false

override var prefersStatusBarHidden: Bool {
    get {
        return statusBarStatus
    }
}

as you can see here, i refer to custom stored parameters for the value i actually want, thus changing the status bar's update is a matter of changing those custom parameters and to call statusBarNeedsUpdate.

Try this approach, if it does not fix your issue, provide code for your controller.

jlmurph
  • 1,050
  • 8
  • 17
  • Tried adding them but still not working :( I edited the question so please have a look – kela Nov 16 '17 at 04:37