簡體   English   中英

SWRevealViewController panGesture問題-IOS / Swift

[英]SWRevealViewController panGesture issue - IOS/Swift

在我的應用程序中,我使用SWRevealViewController來實現側面菜單。 出於某種原因,我不得不在此處將顯示視圖嵌入到導航控制器中,然后再顯示視圖控制器。

這是我的故事板

在此處輸入圖片說明

除了一件事以外,一切都正常。 當我從屏幕的左邊緣拖動到主視圖的右側(平移手勢)時,它會代替我導航到上一個視圖(在本例中是中間視圖,該中間視圖在中間包含一個按鈕),而不是側面菜單。

這是拖動時的樣子

在此處輸入圖片說明

我想避免這種情況,並在像這樣拖動時獲得側面菜單。 有人可以幫我嗎 任何幫助將不勝感激。

編輯:

這是front_view和Rear_view

在此處輸入圖片說明

您需要在所有不想使用滑動手勢的視圖控制器中從導航控制器中刪除popGesture:

  var gestureRecognizer: UIGestureRecognizer? {
    guard let nc = navigationController else { return nil }
    return nc.interactivePopGestureRecognizer
  }

  override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)

    if let gr = gestureRecognizer {
      gr.isEnabled = false
    }
  }

取一個ViewController.swift文件作為初始具有按鈕的ViewController。

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}

swrevealviewcontroller實現中沒有問題,但是導航控制器的本機行為導致了此問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM