Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用segue将数据从UITableView传递到UIViewController_Ios_Swift_Uitableview - Fatal编程技术网

Ios 使用segue将数据从UITableView传递到UIViewController

Ios 使用segue将数据从UITableView传递到UIViewController,ios,swift,uitableview,Ios,Swift,Uitableview,我试图将数据从UITableView传递到UIViewController,以显示更多细节 override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue.identifier == "PassDetail" { let vc = segue.destinationViewController as! ToDoListDetailViewCon

我试图将数据从UITableView传递到UIViewController,以显示更多细节

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

        if segue.identifier == "PassDetail" {

            let vc = segue.destinationViewController as! ToDoListDetailViewController
            let customIndexPath = self.tableView.indexPathForSelectedRow
            vc.titleString = userList[userList.count - customIndexPath!.row - 1].Title
            vc.descriptionString = userList[userList.count - customIndexPath!.row - 1].Description

        }

    }
我创建了一个
segue push depricated
,并设置了相应的标识符

跑步后,什么也没发生。没有崩溃,我试着设置CreatePrintMethods,当我点击一个单元格时,不会调用任何东西

我试图查看字符串中是否有一个值要与print语句一起传递,但我没有听到print语句的回复

即使没有任何数据,当我点击手机时,应用程序至少会崩溃。但事实并非如此

我试着使用不同的片段,比如
show
等等,但都没用

我的代码中有什么遗漏吗

解决方案

我找到了解决办法

这就是我如何理解它的工作原理。 上面的代码传递数据,但不会推送到下一个viewcontroller

为了解决这个问题,我使用了didelectRowAtIndexPath方法并设置了字符串

下面是我的完整工作代码

重写func tableView(tableView:UITableView,didSelectRowAtIndexPath:nsindepath){


根据我的猜测,您没有以编程方式推送segue


从中得到提示,您是否从didSelectRowatineXpath方法推送了该序列?

您应该尝试并看到的第一件事是,是否“userList[userList.count-customindexath!.row-1].Title”有任何值。在设置vc变量后放置一个print语句,看看会发生什么。还要确保您的segue标识符是correct@The_Curry_Man我这样做了,但我没有收到打印语句的回复。即使我的用户列表中没有任何值,它至少应该崩溃,但我没有。我最初试图推动segue,但道具呃,方法是显示序列。但这也不起作用。没关系,但你是用你的DidSelectRowatineXpath方法手动完成的吗?嗯,不,实际上我没有。我有机会的时候会给你回复的。去试试吧
    contentTitle = "Some title" //contentTitle is a global variable

    tableView.deselectRowAtIndexPath(indexPath, animated: true)
    let row = indexPath.row
    performSegueWithIdentifier("PassData", sender: row)

}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

    if segue.identifier == "PassData" {

        let vc = segue.destinationViewController as! ToDoListDetailViewController
        vc.titleString = contentTitle //setting the titleString created from my ToDoListDetailViewController and setting it to contentTitle

    }

}