从导航控制器返回View Controller?

时间:2018-06-07 12:08:46

标签: swift uinavigationcontroller

我是Swift Development的初学者,我一度陷入困境。我有一个ViewController1(入口点),导航控制器和ViewController2。 ViewController2包含 XLPagerTabStrip ,并嵌入在Navigation Controller中。我可以使用下面的代码从ViewController1移动到Navigation控制器。

boolean clicked = false;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup  container,Bundle savedInstanceState) {
View view =  inflater.inflate(R.layout.camera_connection_fragment, container, false);
Button button = (Button) view.findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
  public void onClick(View v) {
    //Put your logic in the if(clicked) control.
    clicked = true // you can delete this line
    (your logic)
  }
});

return view;

}

@Override
   protected void onStart() {
    super.onStart();
    //You can delete the below if check and move your logic to onClick method
    if(clicked) {
     (your logic)
    }
}

现在问题是我无法从导航控制器移回ViewController1。

能够从 ViewController1 - >移动NavigationController - > ViewController2

但无法撤回,即 ViewController1< - NavigationController< - ViewController2

先谢谢。

3 个答案:

答案 0 :(得分:2)

尝试任何一个

window.$ = window.jQuery = require('jquery');

答案 1 :(得分:1)

在您的代码中删除此行:

self.present(navigationController, animated: true, completion: nil)

当你想要回去时,只需致电:

navigationController?.popViewController(animated: true)

答案 2 :(得分:0)

看起来你在一行中遗漏了自己,所以如果你把它更新为这样:

self.navigationController.pushViewController(viewController, animated: true)

现在应该可以工作......