Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 导航菜单swift 2.2_Ios_Swift_Xcode_Menu_Swrevealviewcontroller - Fatal编程技术网

Ios 导航菜单swift 2.2

Ios 导航菜单swift 2.2,ios,swift,xcode,menu,swrevealviewcontroller,Ios,Swift,Xcode,Menu,Swrevealviewcontroller,我使用SWRevealViewController创建了菜单,它连接到整个应用程序,但当我在任何视图中从菜单中选择任何一行时,它首先进入主页。 任何人都知道为什么以及如何解决这个问题 问题的原因是我使用了dispatch\u async(dispatch\u get\u main\u queue(){ )} 菜单代码 extension UIViewController { func addMenu() { navigationController?.navigationBar.bar

我使用SWRevealViewController创建了菜单,它连接到整个应用程序,但当我在任何视图中从菜单中选择任何一行时,它首先进入主页。 任何人都知道为什么以及如何解决这个问题

问题的原因是我使用了dispatch\u async(dispatch\u get\u main\u queue(){ )}

菜单代码

extension UIViewController {
func addMenu() {
    navigationController?.navigationBar.barTintColor = UIColor.redColor()
    var image : UIImage = UIImage(named:"menu")!

    if (varView == 0) {

    }
    else if (varView == 1) {
        dispatch_async(dispatch_get_main_queue(),{

             let update = storyboard!.instantiateViewControllerWithIdentifier("updateuser") as! UpdateUserProfileViewController          

              self.navigationController?.pushViewController(update, animated: false)
      )}
    }

  }
  }

无论你们做什么和UI相关的事情,你们都必须在主队列中。您的代码应该如下所示

DispatchQueue.main.async { 
       let update = storyboard!.instantiateViewControllerWithIdentifier("updateuser") as! UpdateUserProfileViewController          self.navigationController?.pushViewController(update, animated: false)
}

我通过将菜单设置为静态(为所有菜单行创建了8个单元格)解决了此问题,然后将每个单元格设置为segue。

@Amal EL galant请检查多个segue连接。我希望多个segue连接支持英语和阿拉伯语language@AmalEl-galant当您选择一行时,是否可以检查您有多少个segue连接??表示您所有控制器的segue,问题不在segue中我已经使用这一行解决了问题的原因,我应该使用它dispatch_async(dispatch_get_main_queue(),{@AmalEl galant为什么对segue使用dispatch queue?dispatch queue.main.async在swift 3中我使用dispatch_async(dispatch_get_main_queue(),{对于swift 2.2和这一行,这是问题的原因,因为当我删除它时,应用程序工作good@AmalEl-galant所以你的问题解决了?这是因为主队列?我不能删除这行,因为我需要它dispatch_async(dispatch_get_main_queue(),{@AmalEl galant-你能显示SWL吗row@AmalEl-galant-问题不在
调度\u async中(调度获取主队列(),