How to prevent present modally an active controller?

前端 未结 4 1084
情歌与酒
情歌与酒 2021-01-11 16:11

We have 2 controllers: MainVC and ProfileVC. From MainVC we go to ProfileVC with profileButton press (left item on navigation bar).

In Profile VC we hav

4条回答
  •  长发绾君心
    2021-01-11 16:47

    I think u will need to dismiss the LAST viewcontroller first before going back by present modal segue, the viewcontroller is active, so it crash:

    Use this after call segue from mainVC or something u wanted to go back:

    [self dismissViewControllerAnimated:NO completion:nil]
    

    or

    [[self presentingViewController] dismissViewControllerAnimated:NO completion:nil]
    

    or use push segue, it auto add a back button that automatically add back function

提交回复
热议问题