Search code examples
ioscocoa-touchios-universal-app

How to add new both XIB file for Universal app in iOS?


When I create Universal app in my project start, XCode automatically create ViewController class and XIB File for both iPhone and iPad like

ViewController.h
ViewController.m

ViewController_iPhone.xib
ViewController_iPad.xib

I need to add another Class with both iPhone and iPad XIB Files. But when I create new file in XCode, I can only choose XIB file for one thing. If I checked Targeted for iPad checkbox, i can get only XIB file for iPad.

I want to add both iPhone and iPad XIB with class. How can I do that?


Solution

  • You just need to link your ViewController of iPad in inspector like following.

    To link a .xib to a class with Xcode4:

    Open your new added iPad .xib.

    In the placeholder select File's Owner.

    In the third thumbnail choose "Identity Inspector" in right panel, and then edit the "Custom Class" field and enter your class name like (SecondViewController).

    After that you will be okay with XIB file.

    I think my answer can help you.