Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Tom Coomer
1,331 PointsPush segue from UIButton
Hi, I would like to add a verticle push segue to a UIButton. I have tried using the push option but I have now found out that it can only be used in table view controllers. How would I do this from a button?
Tom Coomer
1,331 PointsWill this add a vertical push animation to the segue?
Michael Jones
Python Development Techdegree Graduate 38,554 PointsAh, nah. This wouldn't. I'm sure it's just a extra method added on though.
Tom Coomer
1,331 PointsHow would I do that?
1 Answer
Amit Bijlani
Treehouse Guest TeacherYou can use the push segue as long as you have a navigation controller. If you don't then make sure your view controller is embedded in a navigation controller. In your storyboard select your view controller from the menu select Editor -> Embed in -> Navigation Controller.
Tom Coomer
1,331 PointsBrillian! Thanks. Am I able to change this to a vertical push?
Amit Bijlani
Treehouse Guest TeacherYou can achieve a vertical transition by adding a modal segue. Or write your own custom segue and animation.
Tom Coomer
1,331 PointsIs this the same animation code for when the keyboard appears.
Amit Bijlani
Treehouse Guest TeacherI believe so.
Tom Coomer
1,331 PointsI have added the navigation controller and it works. However, am I able to hide the navigation bar but keep the back button visible?
Amit Bijlani
Treehouse Guest TeacherWhen you create a modal view controller then there is no navigation bar. You can add a button to dismiss the view controller.
Michael Jones
Python Development Techdegree Graduate 38,554 PointsMichael Jones
Python Development Techdegree Graduate 38,554 Points//This will target the method 'buttonPressed'. [self myButton addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];