1

I am in a situation where I need to set the style of a table view to plain if iOS 6 is running, but grouped if iOS 7 is. I am creating my table view from a storyboard.

What would be ideal is if there was a way to somehow set a property of a view in IB depending on the iOS version. Is there something like this?

I was thinking about simply copying all of the attributes (frame, delegate, etc.) into a new table view in the viewDidLoad method, but I then realized that I would have to some how copy the cell styles from within the storyboard table view into the new programatically created table view. Is there some way to do this?

One solution would be to create the table view from code, and just store the table view cells in their own nibs. There are several (7 to be exact) types of cells used which are only used with this table view. Therefore, I am a bit hesitant on this option.

What would be the best approach for solving this issue?

Thanks for any help

elimirks
  • 1,452
  • 2
  • 17
  • 30

1 Answers1

2

The first solution I can think of would be to create two separate table view controllers within your storyboard. One with a plain table view and one with a grouped table view. Both of them would contain your custom cells.

After that I would create two segues segueGroupedTable and seguePlainTable and at a given point in your code you can easily check the version of the current operating system and then performSegueWithIdentifier:sender: respectively.

HTH

anka
  • 3,817
  • 1
  • 30
  • 36
  • Hm. That is an interesting way of accomplishing this. Although, do you know if there is a way to share the same cells between both table views to avoid duplication? – elimirks Feb 13 '14 at 16:51
  • 1
    Answering that comment, apparently you can't :-/ http://stackoverflow.com/questions/9245969/in-a-storyboard-how-to-make-a-custom-cell-for-use-with-multiple-controllers – elimirks Feb 13 '14 at 16:58