Storyboard Segue From View Controller to Itself

前端 未结 9 2139
无人及你
无人及你 2020-12-04 16:39

I am trying to make a mechanism to drill down a file / folder list. The idea is to show the same file list view controller every time the user selects a folder, and show a f

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-04 17:14

    Here's how you can push another instance of the current view controller without defining a segue or hardcoding its own identifier:

    SameViewController *same = [self.storyboard instantiateViewControllerWithIdentifier: self.restorationIdentifier];
    [self.navigationController pushViewController: same animated: YES];
    

    You just need to set the Restoration ID to be the same as Storyboard ID (there's a checkbox for that in IB).

提交回复
热议问题