Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.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 didSelectRowAt-performSegue indexPath.row到具有不同设计的VCs_Ios_Swift_Xcode_Uistoryboardsegue - Fatal编程技术网

Ios didSelectRowAt-performSegue indexPath.row到具有不同设计的VCs

Ios didSelectRowAt-performSegue indexPath.row到具有不同设计的VCs,ios,swift,xcode,uistoryboardsegue,Ios,Swift,Xcode,Uistoryboardsegue,我最近启动了Xcode,我举了一个例子,我做了一个“didSelectRowAt”,从我决定的图像转到我想要的视图。这很好,但现在我想去不同的故事板,而不是使用我的循环视图。这几天来我一直在努力,但我真的不知道该怎么做 这是我的VC class CategoriesVC: UIViewController, UITableViewDataSource, UITableViewDelegate { @IBOutlet weak var categoryTable: UITableView!

我最近启动了Xcode,我举了一个例子,我做了一个“didSelectRowAt”,从我决定的图像转到我想要的视图。这很好,但现在我想去不同的故事板,而不是使用我的循环视图。这几天来我一直在努力,但我真的不知道该怎么做

这是我的VC

class CategoriesVC: UIViewController, UITableViewDataSource, UITableViewDelegate {



@IBOutlet weak var categoryTable: UITableView!

override func viewDidLoad() {
    super.viewDidLoad()
    categoryTable.dataSource = self
    categoryTable.delegate = self


}

    }
}


func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let category = DataService.instance.getCategories()[indexPath.row]
    performSegue(withIdentifier: "ProductsVC", sender: category)
    performSegue(withIdentifier: kitListIdentifier, sender: category)
}


override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if let productsVC = segue.destination as? ProductsVC {
        let barBtn = UIBarButtonItem()
        barBtn.title = ""
        navigationItem.backBarButtonItem = barBtn
        assert(sender as? Category != nil)
        productsVC.initProducts(category: sender as! Category)


    }

}
}

这是我的故事板

Aas你看,我想根据我从第一个VC中选择的图像位置转到KitList。 在这种情况下,位置0

你能给我一些帮助吗

谢谢你可以试试

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)    {
   let category = DataService.instance.getCategories()[indexPath.row]
   if(indexPath.row == 0)
   {
      performSegue(withIdentifier: kitListIdentifier, sender: category)
   }
   else
   {
       performSegue(withIdentifier: "ProductsVC", sender: category)
   }


}

你为什么要做两段?要同时转到两个控制器吗?在
didSelectRowAt
中,读取indexPath.row并使用正确的标识符执行目标序列。在prepareForSegue中,只需检查segue.identifier并执行if/else并对其进行管理。提示一下,带有外部图像链接的帖子通常更难获得帮助,您应该将图像嵌入帖子中以获得更好的反馈。@Lu,不,我不知道,尽管我知道现在正在发生这种情况。我想能够选择我想要的。我要试试这个谢谢。这是推荐的方式吗?谢谢你工作了,太好了。。。开关箱会更好吗?还是同样的东西?这是我推荐的=D,是的,你可以使用switch@XkOltn26当前位置重要的是,如果答案对你有效,你就接受它。这让全球的开发者受益匪浅。如果有人会面临与你类似的问题,你的问题和这个答案将有助于解决这个问题。