Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Sai Kiran Dasika
Sai Kiran Dasika
Courses Plus Student 7,278 Points

Programming a segue programatically

Hey guys does any one know how to perform a segue programatically in X code. I was actually trying out something cool for the photo bombers app in the iOS development section. This segue has to be between a bar button in the navigation bar in the top and a view controller.

2 Answers

Hook up a manual segue between the view controller that has the bar button item and the view controller that you're trying to navigate to by control + dragging from one view controller to the next. Click on the segue and give the segue a name in the Attributes Inspector in the "identifier" field. In your bar button item's IBAction put [self performSegueWithIdentifier:@"segueName" sender:self];