我的模拟器有点奇怪,我希望有人能帮助我。下面的代码在我的 AppDelegate 中。根据正在运行的设备,我有不同的故事板。设备检测代码似乎工作正常,但我在将模拟器硬件 - >设备保持在我想要的位置时遇到问题。
- 项目设置为“通用”,模拟器设置为 iPhone。模拟器将自己更改为 iPhone 模拟器并作为 iPhone 运行。
- 项目设置到 iPad,模拟器到 iPad,作为 iPad 运行。将项目设置回通用,模拟器设置回 iPhone,模拟器将自身重置回 iPad 并将代码作为 iPad 运行。
- 项目设置为 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;
}
}
}