0

I am using a segmented control with 2 segments on one of the tab bar items on my iPhone app. Essentially, I would like to display two different views when each segment is selected - one segment shows a tableview and the other segment shows a mapview.

So, when segment 1 is tapped, a tableview is displayed. And on tap of segment 2, a mapview is displayed. Each view has its own controller and is loaded from its own nib file. Is this possible?

I successfully created the two views (and controllers) and the two segment controls (on the navigation bar) via XCode but have no idea how to proceed next. Any suggestions and sample code to would be most appreciated.

leeks
  • 3
  • 1
  • 3

1 Answers1

0

The View Controller Programming Guide contains sample code and will help you in understanding how to achieve your task.

As far as i understand your situation, i think you should be able to connect the tab bar items to the view controllers with the Interface Builder by configuring the Tab Bar Items with the Inspector.

Frank Martin
  • 2,584
  • 2
  • 22
  • 25
  • Hi Frank, thanks for your answer. I'm not sure if I understand the second part of your answer correctly though. I am actually trying to connect the view controllers to the segment controls and not the tab bar. Essentially, I trying to make use of segment controls to allow me to have two different views for one tab bar item e.g. like the Top 25 tab bar item in the App Store app (which has 3 different views - Top Paid, Top Free and Top Grossing). I took a look at the programming guide and couldn't anything that would help. Any other ideas? – leeks Apr 22 '10 at 11:06
  • Sorry - misunderstood your question obviously! Maybe the answer to the following question can help you further: http://stackoverflow.com/questions/2118358/uisegmentedcontrol-best-practice – Frank Martin Apr 22 '10 at 18:00
  • Thanks for the link, will give it a try - think it answers my question. – leeks Apr 23 '10 at 16:07