您应该首先使用以下代码检查设备,现在您创建两个具有相同类的 xib,一个用于 ipad,第二个用于 iphone,并加载设备明智的..
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
//iphone
}
else
{
//ipad
}
例如
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
masterViewController = [[cntrMasterViewController alloc] initWithNibName:@"cntrMasterViewController_iPhone" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
// loadingView =[LoadingView loadingViewInView:masterViewController.view:@"Please Wait.."];
//masterViewController.view.userInteractionEnabled=NO;
[self.window makeKeyAndVisible];
self.window.rootViewController = self.navigationController;
[self.window addSubview:self.navigationController.view];
}
else
{
cntrMasterViewController *masterViewController = [[[cntrMasterViewController alloc] initWithNibName:@"cntrMasterViewController_iPad" bundle:nil] autorelease];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
UIViewController *viewController1 = [[cntrMasterViewController alloc] initWithNibName:@"cntrMasterViewController_iPad" bundle:nil];
[self.window makeKeyAndVisible];
self.window.rootViewController = self.navigationController;
[self.window addSubview:self.viewController1.view];
}