无法覆盖视图之间的siri菜单按钮

时间:2016-06-17 14:35:23

标签: swift tvos uitapgesturerecognizer siri-remote

因此,我已经能够使用tapGesture识别器成功覆盖菜单按钮的默认行为。我有类似的东西

func addMenuButtonLock() {
    defaultMenuTapRecognizer = UITapGestureRecognizer(target: self, action: Selector())
    defaultMenuTapRecognizer!.allowedPressTypes = [NSNumber(integer: UIPressType.Menu.rawValue)]
    self.view.addGestureRecognizer(defaultMenuTapRecognizer!)
}

func removeMenuButtonLock() {
    if defaultMenuTapRecognizer != nil {
        self.view.removeGestureRecognizer(defaultMenuTapRecognizer!)
        defaultMenuTapRecognizer = nil
    }
}

override func viewWillAppear(animated: Bool) {
    addMenuButtonLock()
    super.viewWillAppear(animated)
}

override func viewDidAppear(animated: Bool) {
    removeMenuButtonLock()
    super.viewDidAppear(animated)
}

override func viewWillDisappear(animated: Bool) {
    super.viewWillDisappear(animated)
    addMenuLock()
}

override func viewDidDisappear(animated: Bool) {
    super.viewDidDisappear(animated)
    removeMenuLock()
}

但似乎在转换和segue期间(如在一个视图控制器被替换/覆盖另一个视图控制器之间的动画中),如果按下它的菜单按钮似乎回退到默认情况下将视图控制器弹出堆栈。我觉得我已经尝试了一切,包括:

  • 根本不删除tapgesturerecognizer
  • 在调用视图外观函数的超级方法之前调用它们
  • 将tapgesturerecognizer添加到基础导航控制器(子类化)
  • 压倒印刷机,按下印刷机并按下印刷机。在这种情况下,它捕获菜单按下,但尽管我从不调用他们的超级方法,视图仍然会弹出。我很失落。

0 个答案:

没有答案