UISegmentedControl Best Practice

Posted by Neal L on Stack Overflow See other posts from Stack Overflow or by Neal L
Published on 2010-01-22T15:39:30Z Indexed on 2010/05/23 8:40 UTC
Read the original article Hit count: 465

Hi all,

I'm trying to work out the "best" way to use a UISegmentedControl for an iPhone application. I've read a few posts here on stackoverflow and seen a few people's ideas, but I can't quite sort out the best way to do this. The posts I'm referring to are:

http://stackoverflow.com/questions/1559794/changing-views-from-uisegmentedcontrol and http://stackoverflow.com/questions/1047114/how-do-i-use-a-uisegmentedcontrol-to-switch-views

It would seem that the options are:

  • Add each of the views in IB and lay them out on top of each other then show/hide them
  • Create each of the subviews separately in IB, then create a container in the main view to populate with the subview that you need
  • Set up one really tall or really wide UIView and animate it left/right or up/down depending on the selected segment
  • Use a UITabBarController to swap out the subviews - seems silly
  • For tables, reload the table and in cellForRowAtIndex and populate the table from different data sources or sections based on the segment option selected (not the case for my app)

So which approach is best for subview/non-table approaches? Which is the easiest to implement? Could you share some sample code to the approach?

Thanks!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about subview