Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change viewcontroller with segmented control in iOS SDK4.2 (storyboard)? need sample code [closed]

I found this great sample code about 'Switching Views with a UISegmentedControl'.

http://redartisan.com/blog?page=2

(sample code link : http://github.com/crafterm/SegmentedControlRevisited)

but this sample code is using xib. I want to re-coding it using storyboard (no xib). Is anywhere similar sample code?

like image 954
jokor7 Avatar asked Nov 14 '22 11:11

jokor7


1 Answers

I did a little trick to be able to do that within the Storyboard.

I have a SplitView Controller with a Master and a Detail view. I created two simple View Controllers with size equal to Detail. Both of them have a Segmented Control with the same two buttons: First and Second. On each view, I added a label representing that View ("First View" and "Second View").

Then, on the first View, I select the "First" button and on the second View, I select the "Second" button.

After that, the only thing remaining is to create segues between them (First View goes to the second and the Second View goes to the First). The type of segue for both of them is "replace".

like image 93
Daniel Ducharme Avatar answered Jan 04 '23 18:01

Daniel Ducharme