just found out a simple way:
alt text http://www.balexandre.com/temp/2010-04-17_1242.png
alt text http://www.balexandre.com/temp/2010-04-17_1241.png
Then, if you want to switch to XIB files per device, let's say, the MainView for iPhone is A and the MainView for iPad is B, in your AppDelegate you add this:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// The default have the line below, let us comment it
//MainViewController *aController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil];
// Our main controller
MainViewController *aController = nil;
// Is this OS 3.2.0+ ?
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
// It's an iPad, let's set the MainView to our MainView-iPad
aController = [[MainViewController alloc]
initWithNibName:@"MainView-iPad" bundle:nil];
else
// This is a 3.2.0+ but not an iPad (for future, when iPhone runs with same OS than iPad)
aController = [[MainViewController alloc]
initWithNibName:@"MainView" bundle:nil];
#else
// It's an iPhone (OS < 3.2.0)
aController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil];
#endif
// Let's continue our default code
self.mainViewController = aController;
[aController release];
mainViewController.view.frame = [UIScreen mainScreen].applicationFrame;
[window addSubview:[mainViewController view]];
[window makeKeyAndVisible];
return YES;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…