0

I have a single view in iPhone and i want to use that as a detail view in my iPad. Unfortunately the exit button in iPhone is used to dismiss the view where in i have used the same view as a detail view in SplitViewController.

As the details view being a child view in splitViewController its giving me error now when i tap on the exit button to dismiss the splitView(obviously).

Any Solutions to this ?

1 Answers1

0

Take all of the differing code for iPhone and iPad and subclass the shared class. Then you can take iPad or iPhone specific actions in the subclass, while still having the core functionality be the same in the superclass. Be sure to change the view controllers in the storyboard to the new subclasses.

So your SingleViewController right now that is being used differently in iPhone vs iPad would become:

                 ParentViewController
                         |
          ---------------------------------
         |                                 |
iPadViewController               iPhoneViewController
(detail view controller)         (single view controller)

Edit:
If there are only a few things that you want to handle differently for each device, or you just don't want to subclass, then you can handle actions differently for each device like so:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    // Code for iPad
} else {
    // Code for iPhone
}
keithbhunter
  • 12,258
  • 4
  • 33
  • 58