简体   繁体   English

迅速3秒TableView segue没有显示在导航控制器中

[英]swift 3 Second TableView segue not showing in Navigation Controller

EDIT 2: Added a half-solution at bottom. 编辑2:在底部添加了一个半解。 Still open to a full solution 仍然有完整的解决方案

EDIT 1: Added images. 编辑1:添加了图像。

I need help fixing navigation between a second and third tableview. 我需要帮助修复第二个和第三个tableview之间的导航。

I have a Navigation Controller, and three table views. 我有一个导航控制器和三个表格视图。 The first two show up fine such that clicking a dynamic tableview cell > in the first tableview moves to the second tableview. 前两个显示很好,因此在第一个表视图中单击动态表视图单元>会移到第二个表视图。 However the second tableview cell chevron > while set in the storyboard (Accessory: Disclosure Indicator) doesn't show up during runtime, and therefore clicking on it does not move to the third tableview. 但是,在情节提要中设置的第二个tableview单元格chevron>(附件:Disclosure Indicator)在运行时不会显示,因此单击它不会移动到第三个tableview。 I need help fixing that. 我需要解决此问题的帮助。

In each case I Ctrl+linked the cells to the next tableview in storyboard as show, and have prepare for segue in the previous tableview controllers. 在每种情况下,我都按Ctrl +键将单元格链接到情节提要中的下一个表格视图,如图所示,并准备在先前的表格视图控制器中进行监视。 However only one works and the other seems orphaned. 但是,只有一部作品和另一部作品似乎是孤立的。

If you could suggest a checklist in making sure the Navigation Controller works across three tableviews that would be helpful. 如果您可以提出一个清单,以确保导航控制器可以在三个表视图中正常工作,那将很有帮助。 Not sure what code to show so I'll post both segues. 不知道要显示什么代码,所以我将同时发布这两个命令。 But it might not be a segue issue so I don't know. 但这可能不是问题,所以我不知道。

first tableview Weeks works going to second tableview Leagues. 第一张Tableview Weeks作品进入第二张Tableview Leagues。 Loads json file depending on what is clicked. 根据单击的内容加载json文件。

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "toLeagues"
    {
            let leaguesController = segue.destination as! LeaguesViewController
            // pass the selected row
            let selectedRow = self.tableView.indexPath(for: sender as! UITableViewCell)!.row
            if selectedRow == 0
            {
                leaguesController.weekFileName = "sports_week_1"
            }
            else
            {
                leaguesController.weekFileName = "sports_week_2"
            }
    }

But second tableview Leagues doesn't work going to third tableview Games 但是第二个Tableview联赛无法进行第三个TableView游戏

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "toGames"
    {

        let gamesController = segue.destination as! GamesViewController
        // pass the selected row
        let selectedRow = self.tableView.indexPath(for: sender as! UITableViewCell)!.row

        gamesController.gameName = selectedRow.description
    }
}

EDIT 1: Added images: 编辑1:添加的图像:

Starts off fine in first tableview... 在第一个表视图中开始正常...
一开始就很好,进入>进入下一个视图

Stops here in second tableview, can't move to third tableview 在第二个表格视图中停在此处,无法移至第三个表格视图 在此处输入图片说明

EDIT 2: Half solution 编辑2:一半解决方案

I found a half solution. 我找到了解决办法。 Menu item now opens new view, only that the chevron appears after the fact. 现在,菜单项将打开新视图,只有该V形符号出现在事实之后。 didSelectRowAt adds the missing disclosure indicator directly and goes to the new view controller. didSelectRowAt直接添加缺少的公开指示器,然后转到新的视图控制器。 Couldn't find a viewWillAppear with IndexPath so I opted for didSelectRowAt. 找不到带有IndexPath的viewWillAppear,所以我选择了didSelectRowAt。 Works when clicked at least. 至少在单击时有效。 Just the disclosure indicator missing on initial load. 只是在初始加载时缺少披露指标。 How to load the accessoryType before the view runs? 在视图运行之前如何加载附件类型?

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

        let cell = tableView.cellForRow(at: indexPath)
        cell?.accessoryType = .disclosureIndicator

        // force menu to move to GamesViewController
        let myGamesView = self.storyboard!.instantiateViewController(withIdentifier: "gamesView")
        self.navigationController?.pushViewController(myGamesView, animated: true)
    }

Try setting accessoryType in cellForRowAt instead of didSelectRowAt . 尝试在cellForRowAt而不是didSelectRowAt设置accessoryType

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "yourIdentifier") as! YourCustomCell

    //Your other code
    cell.accessoryType = .disclosureIndicator
    return cell 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM