ios - 有没有一种特殊的方法可以将 ChildViewController 的成员访问到 ViewController 中,在函数 prepare(for: segue) 中使用其他方法?
问题描述
在制作需要'ContainerView'的基本 iOS 应用程序时遇到逻辑问题。
在 ChildView 中添加了一个标签,并将标签命名为 timerGaugeLabel。
@IBOutlet weak var timerGaugeLabel: UILabel!
(无法将成员访问到 ViewController 类中)
使用函数 prepare(for : segue) 并在函数内部本地创建 segue 实例。
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "ChildViewControllerSegue" {
let childViewController = segue.destination as! ChildViewController
}
}
(数据成员 timerGaugeLabel 可以在函数内访问,但不能在 ViewController.swift 文件中全局访问)
解决方案
推荐阅读
- javascript - 用户在 prompt() 中输入文本;此文本保存在浏览器中,或更改 html 文件本身(首选)
- quickbase - 在 QuickBase 中,有没有办法让一个字段具有唯一的用户访问权限?
- tailwind-css - 如何在框中包含标题作为
- google-bigquery - BigQuery SQL - 向现有记录添加新记录
- c# - 向 ID 令牌 OpenID 添加自定义声明
- reactjs - 如何根据 id 是否匹配 websocket 对象的 id 有条件地呈现列表项
- python - 选择 Python 数据框中的特定单元格(使用 iloc?)
- bash - 在bash中不能乘以负数
- azure - 虚拟机的 Azure Powershell 问题
- javascript - 在 Firefox 中使用 Javascript 检测键盘布局