我的第一个视图上有一个带有单元格的 TableView,它运行良好。但是我想单击某个单元格,然后应该出现带有新表视图和单元格的新视图。但点击后,我只能看到没有任何单元格的 TableView。
SecondViewController 代码
import UIKit
import WebKit
import Kanna
import Gloss
class SecondViewController: UIViewController, UITableViewDelegate,
UITableViewDataSource {
@IBOutlet weak var menuTable: SecondViewControllerTableViewCell!
public func tableView(_ tableView: UITableView,
numberOfRowsInSection section: Int) -> Int {
return 3
}
public func tableView(_ tableView: UITableView, cellForRowAt
indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier:
"lte_secondPage", for: indexPath) as! ViewControllerTableViewCell
return cell
}
override func viewDidLoad() {
super.viewDidLoad()
}
}
FirstViewController 代码
class ViewController: UIViewController, UITableViewDelegate,
UITableViewDataSource {
let logos = ["ks", "vf", "ls"]
func tableView(_ tableView: UITableView, numberOfRowsInSection
section: Int) -> Int {
return logos.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath:
IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier:
"lte_firstPage", for: indexPath) as! ViewControllerTableViewCell
@code@
}
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath:
IndexPath) {
performSegue(withIdentifier: "segue", sender: self)
}
override func viewDidLoad() {
super.viewDidLoad()
}
第一个表单元控制器的代码
import UIKit
class ViewControllerTableViewCell: UITableViewCell {
@IBOutlet weak var logoImage: UIImageView!
@IBOutlet weak var regionQuantity: UILabel!
@IBOutlet weak var localityQuantity: UILabel!
@IBOutlet weak var BSQuantity: UILabel!
@IBOutlet weak var updateDate: UILabel!
@IBOutlet weak var namesOfBS: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
}
第二表单元控制器代码
import UIKit
class SecondViewControllerTableViewCell: UITableViewCell {
@IBOutlet weak var label: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
当我尝试在其中打印一些东西时,
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { print(3) return 3 }它什么也没打印,并且
2019-01-04 22:54:07.057626+0200 BaseStation[12620:273434] <UIView: 0x7f9f52c1e640; frame = (0 0; 375 667); autoresize = W+H; layer = <CALayer: 0x600001a62a80>>'s window is not equal to <BaseStation.SecondViewController: 0x7f9f52c239e0>'s view's window!
在单击第一个视图中的单元格后在调试器中出现