1
我正在製作一個主視圖控制器和一個菜單按鈕的應用程序。通過點擊按鈕,出現另一個視圖控制器作爲側邊菜單,然後用戶可以選擇返回到前一個主視圖控制器。但是,那麼菜單按鈕不起作用了。按鈕功能只能工作一次
主視圖控制器的代碼是在這裏(不是容器視圖控制器):
@objc
protocol CenterViewControllerDelegate {
optional func toggleLeftPanel()
optional func collapseSidePanels()
}
class CenterViewController: UIViewController {
@IBOutlet weak var titleLabel: UILabel!
var delegate: CenterViewControllerDelegate?
@IBAction func MenuTapped(sender: AnyObject) {
delegate?.toggleLeftPanel?()
}
// MARK: Button actions
}
您可以添加toggleLeftPanel()函數的代碼實現嗎? – silentBeep
你可能有一個標誌來檢查,如果側菜單如果打開/崩潰,所以根據該標誌執行toggleLeftPanel()函數,你可以調用collapseSidePanels()函數 – silentBeep