views:

83

answers:

1

I'm making a universal app and I've run across a situation I'm stumped on. On the iPad I'm using a split view, and I would like to make a UITableViewController that is shared on both the iPad and iPhone. I did that, but now when the user clicks a table cell I need to respond. On the iPhone I will init a new view controller and push it in the navigationController stack, but on the iPad I will init a different viewController and display it in the detail view pane. I know how to do each of these actions by its self, but how do I write the UITableViewController so that it knows which action to preform depending if its the iPhone or iPad?

Is there a better way to handle this?

+1  A: 

Here's what I did in that exact same situation.

The table-view controller had a property called detailViewController. If this property is not nil than I updated that view based on what cell was touched. If that property was nil I must be on the iPhone and inside a UINavigationViewController. I use self.navigationController to push my new iPhone view.

kubi
Ok, that makes sense. Thanks
jamone