加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

如何使用iPhone和iPad两个输出启动项目?

发布时间:2020-12-15 01:47:41 所属栏目:百科 来源:网络整理
导读:使用Pre Release Xcode 3.2.3我将其作为启动项目 alt text http://www.balexandre.com/temp/2010-04-17_1155.png 我应该选择/做一个能够同时将iPad和iPhone作为目标的项目(不是在iPad上显示iPhone应用程序而是在真正的iPad视图中)? 谢谢. 为了避免问题: iP
使用Pre Release Xcode 3.2.3我将其作为启动项目

alt text http://www.balexandre.com/temp/2010-04-17_1155.png

我应该选择/做一个能够同时将iPad和iPhone作为目标的项目(不是在iPad上显示iPhone应用程序而是在真正的iPad视图中)?

谢谢.

为了避免问题:

> iPhone OS 3.1.3是iPhone上的最新版本
> iPhone OS 3.2是iPad上的最新版本

我的问题没有违反我和Apple必须达成的任何协议,因为我的问题是那些已经公开发布的问题.

我刚刚说过,在我的操作系统上,我正在运行Xcode 3.2.3,就是这样.

解决方法

刚发现一个简单的方法:

alt text http://www.balexandre.com/temp/2010-04-17_1242.png

alt text http://www.balexandre.com/temp/2010-04-17_1241.png

然后,如果你想切换到每个设备的XIB文件,比如说,MainView for iPhone是A而MainView for iPad是B,你在AppDelegate中添加:

- (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;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读