NewViewController always with two pens (iPhone and iPad)

Configure xcode for generic xib apps so that when I create a new ViewController like VideoVC it ​​has to create two nib files for that type

  • VideoVC_iPhone

  • VideoVC_iPad

Can someone help me. no recommendation. just steps. Thanks to

+3


source to share


4 answers


You will see a templates folder inside "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode" here you will see project files and templates that you can edit or create a new one if you like.

Depending on your question go to this folder "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates"

Here you can achieve what you are trying to do by adding an empty navel for the iPad using the nib view controller template. I downloaded the sample I made, it still works but it will create 2 nibs as needed.

[my custom template]
http://www.saplogix.net/Xcode_Custom_Template/TwoNibTemplate.zip
extract and copy that inside this folder "~/Library/Developer/Xcode/Templates/File Templates"

Note: create the directory if it not already there.

      



Todo: add code to download a specific nib based on the device, which you just need to add as well. Also it will only work for UIViewController as superclass.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    }
    else
        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
        {
            NSString *_nibBundleOrNil = (NSString *)(nibBundleOrNil != nil ? [nibNameOrNil stringByAppendingString:@"_iPad"] : [NSStringFromClass([self class]) stringByAppendingString:@"_iPad"]);
            self = [super initWithNibName:_nibBundleOrNil bundle:nibBundleOrNil];
        }

    if (self)
    {
        // Custom initialization
    }
    return self;
}

      

My template will create the following entry and you can use it to create a dual tip controller. My template will produce the following entry u can use that to create controller with 2 nibs.

+3


source


To do this, you can create your own template controller template. It is easier to create a new file template than to create a new project template, so it can be done.



I gave you a presentation a while ago - the slides might be helpful.

+2


source


Create a viewcontroller with the following naming convention: either create an iphone / ipad xib like "viewcontrollername~iPhone.xib"

or@"viewcontrollername~iPad.xib"

and below link states is the same, provides a way to differentiate ipad and iphone in your viewcontroller.h and viewcontroller.m

http://iphonedevelopment.blogspot.de/2010/04/converting-iphone-apps-to-universal.html

+2


source


When you create your new Xcode project, select the Single View app from the options page, from the Devices drop-down list, select Universal. This will create both iPhone and iPad.

From the beginning to the end:

File -> New Project

Select Application Single View → Next

Devices → Universal

-3


source







All Articles