Ios 未解析标识符的使用“;“绩效考核”;错误
为什么Xcode告诉我performsgue(with identifier:)是一个未解析的标识符?(请参见注释行)Ios 未解析标识符的使用“;“绩效考核”;错误,ios,swift,tableview,segue,Ios,Swift,Tableview,Segue,为什么Xcode告诉我performsgue(with identifier:)是一个未解析的标识符?(请参见注释行) 您的代码中有两个错误: 第27行}应在末尾,因为这将结束课程 您是从UITableViewController继承的,因此需要重写tableView(\utableview:UITableView,didSelectRowAt indexath:indexPath) 编译以下内容的代码: import UIKit class AllListsViewController: U
您的代码中有两个错误:
}
应在末尾,因为这将结束课程UITableViewController
继承的,因此需要重写tableView(\utableview:UITableView,didSelectRowAt indexath:indexPath)
import UIKit
class AllListsViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}
// MARK: - Table view data source
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = makeCell(for: tableView)
cell.textLabel!.text = "List \(indexPath.row)"
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
performSegue(withIdentifier: "ShowChecklist", sender: nil) // Use of unresolved identifier "performSegue"
}
func makeCell(for tableView: UITableView) -> UITableViewCell {
let cellIdentifier = "Cell"
if let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier) {
return cell
} else {
return UITableViewCell(style: .default, reuseIdentifier: cellIdentifier)
}
}
}
尝试将
UIViewController
包含到类中,以解决我的问题:
class AllListsViewController: UITableViewController, UIViewController {
^^^^^^^^^^^^^^^^
我用适当的缩进更新了你的代码。错误现在很清楚了。@NiravD没有额外的
}
。查看带有适当缩进的代码。@NiravD,你几乎是对的,它不是一个额外的{
,但它位于错误的位置。
class AllListsViewController: UITableViewController, UIViewController {
^^^^^^^^^^^^^^^^