【发布时间】:2019-10-15 22:05:22
【问题描述】:
我有一个UITabBarController,我想创建一个只会触发警报视图控制器的项目。
我希望警报显示在按下按钮的视图控制器的顶部。
这是我现在的代码,但由于某种原因它不起作用:
override func viewDidLoad() {
super.viewDidLoad()
self.tabBarController?.delegate = self
}
override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
if item.title == "Title"{
let action = UIAlertAction(title: "OK", style: .default, handler: { (nil) in
self.tabBarController?.selectedIndex = 0
})
let alert = UIAlertController(title: "Feature not active yet", message: "Will be added soon", preferredStyle: .alert)
alert.addAction(action)
present(alert, animated: true, completion: nil)
}
}
它向我显示警报,但不会移动到 OK 操作处理程序中的索引 0。
【问题讨论】:
-
提供您的代码支持的更多详细信息
-
我添加了一些代码,请看看你能不能告诉你是什么问题
标签: ios swift uitabbarcontroller