具有奇怪行为的ios状态栏

标签 ios statusbar navigationcontroller

使用 iOS-9.2 和 Swift-2.1:

使用下面的代码回到我的 rootViewController,不幸的是导致我的应用程序的 status-bar 出现非常奇怪的行为!

    static func returnToRootViewController(sender: AnyObject) {

    let initialscene = sender.storyboard?!.instantiateInitialViewController()
    for _ in sender.view!!.window!.subviews {

        sender.dismissViewControllerAnimated(true, completion: nil)
    }
    sender.view!!.window!.rootViewController = initialscene
    }

下面的两张图片显示了正常状态下的状态栏(即左图)和通过上面的 returnToRootViewController-Code 返回后的状态栏(即带有奇怪颜色的右图)!

在应用上述代码之前,导航 Controller 被导航到几个模态弹出窗口....

在此感谢任何帮助!

enter image description here

最佳答案

您多次关闭同一个 View Controller 。调用 dismissViewController 只会关闭发送者提供的那个,而不是它下面的几个(我假设 sender 是最上面的那个)

从这个答案看来,您似乎可以通过关闭 rootViewController 提供的第一个来关闭所有这些:https://stackoverflow.com/a/23566262/78496

关于具有奇怪行为的ios状态栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34686361/

相关文章:

android - 如何在代号一中获得频繁的后台 GPS 更新?

ios - 如何设置背景色为透明,以显示运营商信息、时间和电池状态

ios - 隐藏导航栏但显示带背景的状态栏

ios - 即使在 CLLocationManager 上明确调用 stopUpdatingLocation 后,状态栏上的位置服务指示器仍然出现

ios - 点击表格单元格时如何推送新的 View Controller ?

ios - 如何从导航 Controller 中删除 View

ios - 将字典映射到 ios 中的 TableView ?

ios - 对 Modal ViewController 被解雇使用react

ios - 为分组 TableView 中的每个部分添加阴影

iphone - 打开接收推送通知的特定 View