0

我想在每次出现 floatingViewController 时隐藏 FabButton,并在关闭视图时再次显示它。

我尝试隐藏 FabButton 本身

self.menuButton.hidden = true

但是当我关闭 floatingViewController 时没有回调函数,所以我没有办法取消隐藏它。

我也尝试手动设置 zPosition 但按钮不受影响

有更好的方法吗?

4

2 回答 2

0

NavigationBarViewController 具有用于检测 floatingViewController 状态的委托方法。设置委托对象,

navigationBarViewController?.delegate = self

然后尝试委托方法:

extension AppNavigationBarViewController: NavigationBarViewControllerDelegate {
    /// Delegation method that executes when the floatingViewController will open.
func navigationBarViewControllerWillOpenFloatingViewController(navigationBarViewController: NavigationBarViewController) {
    print("Will Open")
}

    /// Delegation method that executes when the floatingViewController will close.
func navigationBarViewControllerWillCloseFloatingViewController(navigationBarViewController: NavigationBarViewController) {
    print("Will Close")
}

    /// Delegation method that executes when the floatingViewController did open.
func navigationBarViewControllerDidOpenFloatingViewController(navigationBarViewController: NavigationBarViewController) {
    print("Did Open")
}

    /// Delegation method that executes when the floatingViewController did close.
func navigationBarViewControllerDidCloseFloatingViewController(navigationBarViewController: NavigationBarViewController) {
    print("Did Close")
}

}

您应该能够使用这些方法来达到预期的效果。

于 2016-03-04T00:01:32.767 回答
0

将此方法添加到 FloatingViewController 类

override func viewWillDisappear(animated: Bool) {
  let vc = ...assign to the viewcontroller that holds tour menu button 
  vc.menuButton.hidden = false
}
于 2016-03-04T00:02:56.193 回答