定制Xcode的普遍应用xibs,所以,当我创建一个像VideoVC一个新的视图控制器,它必须创建两个笔尖文件,像,newViewController总是有两个笔尖(iPhone和iPad)
VideoVC_iPhone
VideoVC_iPad
有人能帮助我。没有指引。只是步骤。谢谢
定制Xcode的普遍应用xibs,所以,当我创建一个像VideoVC一个新的视图控制器,它必须创建两个笔尖文件,像,newViewController总是有两个笔尖(iPhone和iPad)
VideoVC_iPhone
VideoVC_iPad
有人能帮助我。没有指引。只是步骤。谢谢
您将看到模板文件夹里面的“/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。
当您创建新的Xcode项目时,请在选项页面上的设备下拉列表中选择单一视图应用程序,选择通用。这将创建iPhone和iPad的笔尖。
从开始到结束:
文件 - >新建项目
选择单查看应用程序 - >下一步
设备 - >通用
它只是第一次创建。如何创建第二次或更多 – junaidsidhu
您可以创建一个自定义视图控制器模板做这个。创建新文件模板比创建新项目模板更容易,因此完全可以这样做。
前段时间我给出了一个演示 - the slides可能会有用。
您可以向我发送与我的幻灯片链接 – junaidsidhu
我已将该链接添加到答案。 – Abizern
具有以下命名约定创建一个视图控制器,可以创建iPhone/iPad的厦门国际银行作为"viewcontrollername~iPhone.xib"
或@"viewcontrollername~iPad.xib"
和下面的链接状态相同,提供了方法来区分iPad和iPhone在viewcontroller.h和viewcontroller.m
http://iphonedevelopment.blogspot.de/2010/04/converting-iphone-apps-to-universal.html
但这并不创建模板,一个XIB的iphone和另一个ipad – Vinodh
我正在为此创建一个开源的Google项目,并将上传我已完成和未来的工作,我将这样做,如果你有任何其他模板记住让我知道。 [Google Project - Xcode自定义模板](http://code.google.com/p/xcode-custom-templates/) – SAPLogix
不要将文件添加到Xcode文件夹 - 升级Xcode时,您将失去更改。自定义模板的正确位置是'〜/ Library/Developer/Xcode/Templates /'。如果它不存在,你需要创建它。 – Abizern
@Abizern谢谢你指出,我已经更新了我的答案中的路径。 – SAPLogix