作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在做项目时遇到了一个奇怪的问题。 (请耐心等待,我是 Swift 初学者。)
这就是我到目前为止的 Storyboard的样子。 On the left is my regular view controller, and on the right is the TableViewController. the transition inbetween has a specific ID.
**This is the first View Controller.**
class TestsMenuViewController: UIViewController {
var tests = [Test]()
var testTableViewController : TestsTableViewController?
override func viewDidLoad() {
self.tests = DataModel().patientData
//this just populates the array with some data.
super.viewDidLoad()
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "testTableTransition" {
testTableViewController = segue.destination as? TestsTableViewController
testTableViewController?.tests = self.tests
print(testTableViewController?.tests[0].testDescription)
//somehow this is an empty array
}
}
不知何故,测试数组没有传递到下一个 Controller :(我做错了什么?
最佳答案
您可以将数据保存为 NSUserDefaults 并在需要时将保存的数据调用到 View
关于ios - 无法将数据从一个 View Controller 推送到 TableView Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40850681/
我是一名优秀的程序员,十分优秀!