如果一开始就考虑到一个项目工程同时支持iPhone与iPad,那么建立项目的时候就在Device Family 那里选择Universal
如果之前只是选择了iPhone,后来想改还是可以的。在工程的Summary 的iOS Application Target 的 Devices 的值设为Universal
然后新建是iPad类型的xib,把xib的File's Owner改成对应的Controller,把xib的view与File's Owner 的 view 连接
然后在实例化一个Controller的时候加个判断,使其对应不同的xib进行加载
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease];
}else {
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil] autorelease];
}