当音频在swift 3中播放时如何进入当前的viewController?

时间:2017-02-12 06:34:10

标签: swift swift3

目前,我构建简单的应用程序音乐,如果我将当前的viewcontroller(musicController)播放到另一个控制器并且我创建了一个按钮" NowPlaying"把另一个控制器放到我当前的viewcontroller(musicController)上,不加载任何视图。请帮帮我

谢谢

1 个答案:

答案 0 :(得分:1)

试试我的工作代码,

var currentTopMostChildCont: UIViewController = self.getCurrentTopMostChildController()


func getCurrentTopMostChildController() -> UIViewController {
    var topController: UIViewController = UIApplication.sharedApplication().keyWindow.rootViewController
    while topController.childViewControllers.count() > 0 {
        topController = topController.childViewControllers.last //You can track your viewController which you want & get it.
    }
    return topController
}

我希望这肯定能帮助你。