ios - 如何快速更改非 viewController 类中的 ViewController?
问题描述
我在应用程序中使用 ble。当我点击一个启动 ble 的按钮时,BluetoothController 类正在工作。它工作得很好,但是当进入连接设备的过程时,我想显示可以连接的设备。所以我制作了一个包含 tableview 的新 ViewController。并创建了一个设备,称为 ViewController。但是当调用那个类时,我得到了“展开可选值”错误。我知道错误发生的时间。但我不知道为什么以及在哪里是零。
起初在蓝牙控制器中,我得到了presentedView。因为它不是 ViewController。
var topController = UIApplication.shared.keyWindow!.rootViewController!
if topController.presentedViewController != nil
{
topController = topController.presentedViewController!
}
topController.show(bv!, sender: nil)
发生错误的 ViewController 包含 tableview。
BleAlertTableView.dataSource = self
我认为 AlertViewController(contain tableview) 无关紧要。我认为 topController 和改变 ViewController 的方法可能很重要。
解决方案
推荐阅读
- mongodb - 如何在 MongoDB 中为用户分配身份验证机制
- python - 以下行完成了什么?
- python - 具有多个参数的 Lambda
- python - 将csv数据提取成xml格式
- filter - 消息过滤器 onUnaccepted 在自定义策略 mule 3 中的“mule:choice”中使用时不会中断执行
- mongodb - 我是 mongoDB 的新手,需要一个查询来删除集合
- python - 用一系列值替换数据框中的单元格
- maven - 仅部署一个 javadoc
- javascript - 使用 React-Router-Config 设置页面标题
- javascript - 谷歌甘特图将 X 轴移动到顶部而不是底部