开发者

Universal app design 1 table view that opens different view on cell click depending if on iPad or iPhone

开发者 https://www.devze.com 2023-01-07 17:31 出处:网络
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开发者_如何学C a UITableViewController that is shared on both

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开发者_如何学C 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 UINavigationController stack, but on the iPad I will init a different UIViewController 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消