我对我的模拟器有些奇怪,我希望有人可以帮助我。下面的代码在我的AppDelegate中。我有不同的故事板,具体取决于正在运行的设备。设备检测代码似乎工作正常,但我在将模拟器硬件 - >设备保存到我想要的地方时遇到了问题。
....和多种不同的变化。尝试多次重启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;
}
}
}
答案 0 :(得分:1)
如果我正确地理解了您的问题,那么您遇到的问题是您在iPad模拟器中运行应用程序时遇到困难,因为它不断变回iPhone。这是因为您需要在顶部工具栏的Xcode中选择要运行应用程序的模拟器:
执行此操作后,单击“运行”,您选择的iOS模拟器应该打开并运行您的应用程序。