Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.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
根据选定的UITableViewCell打开多个swift文件之一_Swift_Uitableview_Uiviewcontroller_Swift2_Uistoryboardsegue - Fatal编程技术网

根据选定的UITableViewCell打开多个swift文件之一

根据选定的UITableViewCell打开多个swift文件之一,swift,uitableview,uiviewcontroller,swift2,uistoryboardsegue,Swift,Uitableview,Uiviewcontroller,Swift2,Uistoryboardsegue,我有一个应用程序,它以数组的形式由许多不同的问题组成。我将这些数组放入不同的swift文件中,即QuestionsFile1.swift、QuestionsFile2.swift、QuestionFile3.swift、QuestionFile4.swift……等等 我有一个UITableView,它在表视图的每个单元格中显示这些不同的部分,即问题1、问题2、问题3、问题4……等等 我将其设置为,当选择UITableViewCell时,它将显示与swift文件关联的viewController。

我有一个应用程序,它以数组的形式由许多不同的问题组成。我将这些数组放入不同的swift文件中,即QuestionsFile1.swift、QuestionsFile2.swift、QuestionFile3.swift、QuestionFile4.swift……等等

我有一个UITableView,它在表视图的每个单元格中显示这些不同的部分,即问题1、问题2、问题3、问题4……等等

我将其设置为,当选择UITableViewCell时,它将显示与swift文件关联的viewController。然而,这意味着我在故事板上制作了很多viewController

如何仅拥有一个viewController并根据所选的UITableViewCell使用不同swift文件中的问题填充它

我选择使用调用UIViewController

           override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

        if indexPath.row == 0 || indexPath == 1 {
            self.performSegueWithIdentifier("QuestionsFile1", sender: self)
        }


        if indexPath.row == 1 {
            self.performSegueWithIdentifier("QuestionsFile2", sender: self)
        }

        if indexPath.row == 2 {
            self.performSegueWithIdentifier("QuestionsFile3", sender: self)
        }

        if indexPath.row == 3 {
            self.performSegueWithIdentifier("QuestionsFile4", sender: self)
        }

        if indexPath.row == 4 {
            self.performSegueWithIdentifier("QuestionsFile5", sender: self)
        }

        if indexPath.row == 5 {
            self.performSegueWithIdentifier("QuestionsFile6", sender: self)
        }

        if indexPath.row == 6 {
            self.performSegueWithIdentifier("QuestionsFile7", sender: self)
        }
    } 

我只想调用一个视图控制器,然后根据所选的UITableViewCell在不同的swift文件中填充问题。因为我有很多视图控制器,而我认为我可以有一个

是的,您是对的-看起来您在问题文件表中更改的只是内容,因此您应该有一个带有tableView的单一视图,并根据您想要的问题填充它


您可能应该将问题存储在数据文件中,而不是将其硬编码为swift类,因此请查看应用程序包中的文本文件,或众多轻量级数据库中的一个—Realm或(可能是过度使用的)CoreData。

谢谢:)。你有推荐的教程或例子吗?我是Ray Wenderlich教程的超级粉丝-你应该在这里找到你需要的一切-