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

iOS

Switching views in storyboard with segmented control.

I have 3 views in my app which are currently being switch between using buttons. However I would like to change this so they switch with a segmented control. Each view has its own view controller with .h and .m files. How would I do this?

2 Answers

Ok. Each view has multiple timers inside them through their files. Will I need to put them all in to the same .m file?

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

Can you please elaborate on this

Each view has multiple timers inside them through their files.

At the moment the game has 3 views and inside each has a timer. Each of those views have their own .m and .h files.

This is the game.

https://itunes.apple.com/gb/app/reaction-timer-game/id572319874?mt=8

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

You can solve this problem several ways. Using a tab controller or some other third party controller like JASidePanels

Okay. Thanks very much.

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

You don't need to create a separate view controller for each view. You should have all three views in the same view controller and just show / hide them based on which segment was clicked within the segmented control.