
[英]how to pass data from a particular row of a tableview to another view controller using SWrevaelviewController swift 3
[英]how to pass tableview index path row value in another controller in swift?
在我的应用程序中,我使用了标签栏控制器,在那些视图控制器中使用了tableview。 当我单击一个表的行值时,它的值可以在另一个视图控制器中访问。 我尝试使用segue,但是它会给出错误“无法使用仅在导航控制器中使用的segue”,我该怎么办? 谢谢
这是我的代码。
var row = ""
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
row = itemid[indexPath.row]
var db1 = NewVehicalViewController()
db1.temp = row
self.performSegueWithIdentifier("updatevehicalsegue", sender: tableView)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if(segue.identifier == "updatevehicalsegue"){
var vrc = segue.destinationViewController as NewVehicalViewController;
vrc.temp = row
}
}
您的UITableViewController
需要嵌入到UINavigationController
。
为此,请在情节提要中选择tableViewController对象,转到顶部的“ Editor
”,选择“ Embed In
然后选择“ Navigation Controller
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.