私はカスタムUITabBarControllerを持っており、いくつかのビューコントローラがリレーションシークエンスとして追加されています。私はどのビューコントローラを選択しているかを知りたい。私は処理していますカスタムUITabBarController selectedController
override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
guard let controller = self.selectedViewController else {
fatalError("No controller selected")
}
// but controller always come as UIViewController and not strongly typed controller
}
タイプ(of: 'self.selectedViewController')を使用して、' UIViewController'のタイプを決定します。 –
typeという名前のメソッドはありませんか? –
自動入力されません。どうしてか分かりません。あなたはそれを使うことができます。 https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Types.html –