如果在视图

时间:2016-12-23 12:21:38

标签: swift uitableview uiviewcontroller

我分别有UIViewControllerUITableViewControllerABA通过push segue与B相关联。 B包含一个按钮,当按下该按钮时,切换选择B tableView中行的功能。当用户选择行时,底部工具栏会显示一组按钮。

我的问题是,如果我按下选择按钮以显示工具栏,然后按后退按钮返回A,然后再次转到B。当我按下选择按钮时,工具栏不会显示,即使" flag2"在控制台中打印。

@IBAction func selectButtonPressed(_ sender: UIButton) {
    if isSelecting {
        print("flag1")
        selectButton.setTitle("Select", for: .normal)
        navigationController?.setToolbarHidden(true, animated: true)
    }
    else {
        print("flag2")
        selectButton.setTitle("Cancel", for: .normal)
        navigationController?.setToolbarHidden(false, animated: true)
    }
    isSelecting = !isSelecting
}

0 个答案:

没有答案
相关问题