代码之家  ›  专栏  ›  技术社区  ›  Grymjack

xcode模拟器在尝试测试不同的故事情节时不断更改硬件设备模式

  •  3
  • Grymjack  · 技术社区  · 12 年前

    我的模拟器有点奇怪,我希望有人能帮助我。下面的代码在我的AppDelegate中。根据运行的设备不同,我有不同的故事板。设备检测代码似乎工作正常,但我在保留模拟器硬件方面遇到了问题->我想要的设备。

    1. 项目设置为“通用”,模拟器设置为 苹果手机。模拟器将自行更改为iPhone模拟器 并作为iPhone运行。
    2. 项目设置为iPad,模拟器为iPad,以iPad运行。设置 项目回到通用,模拟器回到iPhone,模拟器 将自身重置回iPad,并将代码作为iPad运行。
    3. 项目设置为iPhone,将模拟器留在iPad上。以 iPad上的iPhone应用程序??

    …以及多种不同的变体。尝试多次重新启动Mac和xcode,但没有效果。如果我重置模拟器并在模拟器上运行项目图标,而不是通过xcode,模拟器将保持在我设置的硬件模式。有什么想法吗??


    -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        // testing for iPad detection
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        {
            // setting storyboard name
            [[Data sharedData] setStoryboardName:@"MainStoryboardPad"];
    
            // going to the 4" screen story board and settng it as the root controller
            self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
            UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboardPad" bundle:nil];
            UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"Intro Screen"];
    
            // making that tab controller the root controller
            self.window.rootViewController = viewController;
            [self.window makeKeyAndVisible];
            return YES;
        }
        else
        {
            // detecting screen size
            if (([UIScreen mainScreen].scale == 2) && ([[UIScreen mainScreen] bounds].size.height == 568))
            {
                // setting storyboard name
                [[Data sharedData] setStoryboardName:@"MainStoryboard40"];
    
                // going to the 4" screen story board and settng it as the root controller
                self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
                UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard40" bundle:nil];
                UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"Intro Screen"];
    
                // making that tab controller the root controller
                self.window.rootViewController = viewController;
                [self.window makeKeyAndVisible];
                return YES;
            }
            else
            {
                // setting storyboard name
                [[Data sharedData] setStoryboardName:@"MainStoryboard35"];
    
                // going to the 3.5" screen story board and settng it as the root controller
                self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
                UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard35" bundle:nil];
                UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"Intro Screen"];
    
                // making that tab controller the root controller
                self.window.rootViewController = viewController;
                [self.window makeKeyAndVisible];
                return YES;
            }
        }
    }
    
    1 回复  |  直到 12 年前
        1
  •  1
  •   Greg    11 年前

    如果我正确理解你的问题,你的问题是你很难在模拟器中用iPad运行你的应用程序,因为它一直在变回iPhone。这是因为您需要在顶部工具栏的Xcode中选择要在哪个模拟器中运行应用程序:

    Click on the menu

    Choose the simulator you want to run as

    完成后,单击“运行”,您选择的iOS模拟器将打开并运行您的应用程序。