Reputation: 539
I'm having some weirdness with my simulator and I'm hoping that someone can help me. The code below is in my AppDelegate. I have different storyboards depending on which device is running. The device detection code seems to work fine, but I'm having problems keeping the simulator Hardware->Device where I want.
....and multiple different variations. Tried restarting the Mac and xcode multiple times, no effect. If I reset the simulator and run the project icon on the simulator rather than through xcode, the simulator stays in the Hardware mode I put it in. Any thoughts out there??
-(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;
}
}
}
Upvotes: 3
Views: 380
Reputation: 9168
If I understood your question correctly, the problem you're having is you're having difficulty running your app in the simulator as an iPad, because it keeps changing back to iPhone. This is because you need to select which simulator you want to run the app in in Xcode, in the top toolbar:
After doing that, click run and the iOS simulator you chose should open and run your app.
Upvotes: 1