iPhone应用程序到IPad应用程序如何从ViewController.xib转换到ViewController-iPad.xib?

时间:2011-11-17 07:43:36

标签: iphone objective-c xcode ipad

我正在使用XCode 4.0。

我是从iPhone应用程序转换为IPad作为通用应用程序吗?

我对xib文件有些怀疑?

我应该为每个UIElement使用autoresize元素吗?

Trasit each xib file to the ipad xib file?
How? Could not get the option for that?

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:1)

为iPad和iPhone以及initWithNibName:bundle:使用不同的.xib文件。使用此块确定是使用一个还是另一个

NSString *nibName = nil;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
  nibName = @"CustomViewControllerIpad";
}
else {
  nibName = @"CustomViewControllerIphone";
}

CustomViewController *viewController = [[CustomViewController alloc] initWithNibName:nibName bundle[NSBundle mainBundle]];

[self.navigationController pushViewController:viewController animated:YES];
[viewController release];
相关问题