How do i set a modal segue (programmatically) to a push segue

风格不统一 提交于 2019-11-29 11:44:01

Alternatively, I actually prefer to define a segue right in my storyboard, but rather than originating from the button, I have it originate from the view controller itself, e.g.:

Then, give that segue a "storyboard id", say "Details", and then you can invoke that segue programmatically via:

[self performSegueWithIdentifier:@"Details" sender: ...]; // you can specify either the button or `self` for the `sender

I like this because that way, the storyboard continues to visually represent the flow of the app (as opposed to possibly having scenes floating out there with no segues). And you can use the exact same construct for both push and modal segues (and the view controller that's presenting the next view controller doesn't care which one the storyboard uses).

[self.navigationController pushViewController:Holes animated:YES];

Got it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!