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

时间:2013-03-11 08:52:03

标签: xcode storyboard ios-simulator hardware device

我对我的模拟器有些奇怪,我希望有人可以帮助我。下面的代码在我的AppDelegate中。我有不同的故事板,具体取决于正在运行的设备。设备检测代码似乎工作正常,但我在将模拟器硬件 - >设备保存到我想要的地方时遇到了问题。

  1. 项目设置是' Universal'并将模拟器设置为 苹果手机。模拟器将自己更改为iPhone模拟器 并以iPhone身份运行。
  2. 项目设置为iPad,模拟器设置为iPad,以iPad运行。组 项目回到通用,模拟器回到iPhone,模拟器 重置为iPad并将代码作为iPad运行。
  3. 将项目设置为iPhone,将模拟器留在iPad上。作为一个运行 iPad上的iPhone应用程序??
  4. ....和多种不同的变化。尝试多次重启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 个答案:

答案 0 :(得分:1)

如果我正确地理解了您的问题,那么您遇到的问题是您在iPad模拟器中运行应用程序时遇到困难,因为它不断变回iPhone。这是因为您需要在顶部工具栏的Xcode中选择要运行应用程序的模拟器:

Click on the menu

Choose the simulator you want to run as

执行此操作后,单击“运行”,您选择的iOS模拟器应该打开并运行您的应用程序。