【发布时间】:2017-11-03 00:43:06
【问题描述】:
大家好,我在使用滑出式菜单运行应用程序时遇到 2 个错误
class ViewController: UIViewController {
@IBOutlet var open: UIBarButtonItem!
@IBOutlet var label: UILabel!
var varView = Int()
override func viewDidAppear(_ animated: Bool) {
open.target = revealViewController()
open.action = #selector(SWRevealViewController.revealToggle(_:))
_ = UIStoryboard(name: "Main", bundle: nil)
let vc = (storyboard?.instantiateViewController(withIdentifier: "mainpullout"))! as UIViewController
present(vc, animated: true, completion: nil)
}
@IBAction func toMain(_ sender: AnyObject?) {
_ = UIStoryboard(name: "Main", bundle: nil)
}
}
这是我的滑出控制器类,用于控制表格中的所有视图
class BackTableVC: UITableViewController {
var TableArray = [String]()
override func viewDidLoad() {
TableArray = ["Camps","Lessons","Staff","Classes","Calendar","News","Forums","Locations","Services","Home"]
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return TableArray.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: TableArray[indexPath.row], for: indexPath) as UITableViewCell
cell.textLabel?.text = TableArray[indexPath.row]
return cell
}
}
我觉得我做错了什么,但是当我运行我的应用程序时,用于打开滑出菜单的按钮的视图只是上下弹跳一百万次,这是错误消息之一
在分离的视图控制器上呈现视图控制器是 气馁
【问题讨论】:
-
您填写的数据有误。阅读一些关于如何在 Swift 中实现
UITableView -
JuicyFruit 你是说我如何输入我的表格代码来说明我需要显示的内容是错误的,如果是这样你对我如何解决它有任何想法
-
let cell = tableView.dequeueReusableCell(withIdentifier: TableArray[indexPath.row], for: indexPath) as UITableViewCell错了,查看UITableView教程了解什么是cell id