![](/img/trans.png)
[英]Unwind Segue using performSegueWithIdentifier - Doesn't work - Swift 2.1
[英]performSegueWithIdentifier doesn't work - Swift
我试图在用户点击表视图的一行时使用performSegueWithIdentifier。 但是,它不起作用,并且下一个错误是:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not perform segue with identifier 'categoriesS'. A segue must either have a performHandler or it must override -perform.'
我用错误搜索了一下,但是什么也没找到。 我已经在情节提要中创建了推送脚本,并为它们设置了我在代码中使用的标识符。 这是我的代码(PD:我使用此表视图作为侧边栏菜单):
import Foundation
class menuVC: UIViewController,UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var ProfileImage: UIImageView!
@IBOutlet weak var myTable: UITableView!
var opciones = [String]()
var segues = [String]()
override func viewDidLoad() {
super.viewDidLoad()
myTable.delegate = self
opciones = ["Categories","My Coins","Get Coins","Share","LogOff","Exit"]
segues = ["categoriesS","myCoinsS","getCoinsS"]
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 6
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
print(opciones[indexPath.row])
self.performSegueWithIdentifier(segues[indexPath.row], sender: self)
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell
cell.textLabel?.text = opciones[indexPath.row]
return cell
}
}
谢谢!
您输入了错误的命令,因为控制台明确指出了这一点。 您正在寻找“ categoriesS
”这是在“ segue
”数组,但你是从“传递opciones
”阵列。 仔细看。
编辑我看到了您的编辑,看起来您已使用其他数组填充了表格,但是您在didselectrow中使用了其他数组。请检查一下
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.