segue放松后,TableView消失

时间:2017-12-26 06:14:18

标签: swift uitableview uiviewcontroller uinavigationcontroller uistoryboardsegue

我花了一整天的时间试图解决这个问题,希望能够深入了解这里发生的事情:

我有gtk_entry_set_text(GTK_ENTRY(app_wid->ent_date), "");嵌入UITableViewController的自定义navigation controller,并且它有一个按钮,可以触发普通UIViewController

普通UIViewController有一个展开TableViewController的按钮,以及" back"由于navigation controller而免费提供的按钮。

现在问题:当我从TableViewController转到UIViewController时,一切正常。来自UIViewController,如果我按下"返回"按钮,它会回退,TableView会自动重新加载。但是,当我按下链接到@IBAction的按钮来展开时,它会展开TableViewController,但什么也没有显示,甚至没有空表。

我的调试视图显示,一旦我尝试使用我的按钮(而不是"后退)放松,TableViewController会回到屏幕上,但它的框架非常小而且没有任何内容,因此黑色背景navigation controller正在显示,因此只是一个黑色的屏幕,表格应该是。

有人可以告诉我如何在我放松时手动重新初始化tableView或重置TableViewController吗?我在tableView.reload()中尝试viewDidAppear(),但没有任何反应,因为我怀疑问题是TableViewController本身没有像之前的原始框架一样。

Link to screenshots with descriptions

TableViewController代码:

class StatsTableViewController: UITableViewController {
    //variable stuff

    @IBAction func unwindToRoot(_ sender: UIStoryboardSegue) {
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        self.getData()
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        DispatchQueue.main.async {
            self.tableView.reloadData()
        }
        self.getData()
    }   

    // MARK: - Table view data source

    override func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return solves.count
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! StatsTableViewCell
        cell.timeLabel?.text = solves[indexPath.row].0
        cell.scrambleLabel?.text = solves[indexPath.row].1
        return cell
    }

    //other stuff
}

1 个答案:

答案 0 :(得分:0)

您在statusTableViewController

中使用这两种方法
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
            if segue.identifier == "SelectionSegue" {
                //Your code
            }
        }

        @IBAction func unwindToThisView(sender: UIStoryboardSegue) {
            // set Delegate datasource method
        }

为unwindToThisView按钮设置插座以查看图像

1.单击最后一个ViewController的退出按钮 enter image description here

请参阅显示后退按钮的分段插座

enter image description here

设置后退按钮的动作

enter image description here

相关问题