How to start a project with both outputs iPhone & iPad?

前端 未结 2 618
长情又很酷
长情又很酷 2020-12-09 14:10

Using the Pre Release Xcode 3.2.3 I get this as a Startup Project


(source: balexandre.com)

What should I chose / do to great a project that c

相关标签:
2条回答
  • 2020-12-09 14:52

    You can choose the Application Type as "Universal" .

    0 讨论(0)
  • 2020-12-09 14:57

    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;
    }
    
    0 讨论(0)
提交回复
热议问题