gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 09:53:12 24 4
gpt4 key购买 nike

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

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

最佳答案

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

Click on the menu

Choose the simulator you want to run as

完成后,点击运行,您选择的 iOS 模拟器应该会打开并运行您的应用。

关于xcode模拟器在尝试测试不同的故事情节时不断改变硬件设备模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15334425/

24 4 0
文章推荐: java - Spark : Creating Object RDD from List RDD