2013-02-05 29 views

回答

3

您将看到模板文件夹里面的“/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode” 在这里你会看到文件和临时项目如果你愿意,你可以编辑或创建一个新的。

具体到你的问题,定位到该文件夹​​“/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File模板”

在这里,您可以实现通过在带有笔尖的视图控制器的模板中添加iPad的空白笔尖来尝试执行的操作。我上传了一个样本,它仍然是一个正在进行的工作,但它会根据您的需要创建2个笔尖。

[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's not already there. 

待办事项:添加代码来加载特定的笔尖基于设备,这也是只需要添加。它也只能作为超级类的UIViewController。

- (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; 
} 

我的模板将产生以下条目你可以使用它创建控制器与2个nibs。 My template will produce the following entry u can use that to create controller with 2 nibs.

+0

我正在为此创建一个开源的Google项目,并将上传我已完成和未来的工作,我将这样做,如果你有任何其他模板记住让我知道。 [Google Project - Xcode自定义模板](http://code.google.com/p/xcode-custom-templates/) – SAPLogix

+1

不要将文件添加到Xcode文件夹 - 升级Xcode时,您将失去更改。自定义模板的正确位置是'〜/ Library/Developer/Xcode/Templates /'。如果它不存在,你需要创建它。 – Abizern

+0

@Abizern谢谢你指出,我已经更新了我的答案中的路径。 – SAPLogix

-3

当您创建新的Xcode项目时,请在选项页面上的设备下拉列表中选择单一视图应用程序,选择通用。这将创建iPhone和iPad的笔尖。

从开始到结束:

文件 - >新建项目

选择单查看应用程序 - >下一步

设备 - >通用

+0

它只是第一次创建。如何创建第二次或更多 – junaidsidhu

2

您可以创建一个自定义视图控制器模板做这个。创建新文件模板比创建新项目模板更容易,因此完全可以这样做。

前段时间我给出了一个演示 - the slides可能会有用。

+0

您可以向我发送与我的幻灯片链接 – junaidsidhu

+0

我已将该链接添加到答案。 – Abizern