Dismissing Modal View Controllers

后端 未结 4 1530
温柔的废话
温柔的废话 2021-01-21 20:25

View Controller A presents View Controller B modally, which has a button to present View Controller C modally.

Here is my flow:

A presents B which presen         


        
4条回答
  •  庸人自扰
    2021-01-21 20:49

    You should use a UINavigationController to do this.

    *create a navigation controller with controller B as the root view controller. *A present the navigation controller as a modal with presentModalViewControler:animated: this will have the same affect as presenting B *When B needs to present C it pushes it ti the navigation view comptroller's stack by calling [self.navigationController pushViewController:C animated:YES] *if C needs to be dismissed to revile B you can do those by calling [self.navigationController popViewControllerAnimated:YES] *If C needs to dismiss and revile A you can dismiss the modal by calling [self.navigationController.parentViewController dismissModalAnimated:YES]

    you could go 1 step further and not use a modal at all by embedding A as the root view controller of a navigation controller and pushing B to the Navigation controller instead of presenting it as a modal

提交回复
热议问题