问题
I have a simple app where the UI is created using storyboard. I have a login screen with an icon and a login button. It is showing up when I run on iPhone, but on iPad. Both in simulator and on device.
To check if it was due to my constraints, I just dropped one label without any constraints and view with blue background. Even these are not showing up. Build settings has Deployment Info --> Devices set to Universal.
Any pointers to what is wrong will be greatly appreciated.
EDIT
I tried the following. In my app, after successful login, UI enters a tab-view controller. If I disable the showing of login screen, the app is entering the tab view controller and displaying it properly on the iPad too. I have no idea why the login screen is not showing up on the iPad.
EDIT to add details requested by Islam
Code
AppDelegate, checks if user is logged in. If no, shows the login screen else shows the TabViewOCntrolelr. The TabViewCOntroller part is showing up on the iPad and iPhone
if([GIDSignIn sharedInstance].currentUser.authentication == nil)
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
LoginViewController *viewController = (LoginViewController *)[storyboard instantiateViewControllerWithIdentifier:@"loginScreen"];
[self.window makeKeyAndVisible];
[self.window.rootViewController presentViewController:viewController
animated:NO
completion:nil];
}
else
{
if(![self.gotUserprefs isEqualToNumber:@(YES)])
{
UIUserNotificationType types = UIUserNotificationTypeBadge |
UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
self.mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
}
[[UIApplication sharedApplication] registerUserNotificationSettings:self.mySettings];
[application registerForRemoteNotifications];
//To Do add silent sign-in logic
}
ViewCOntroller code does nothing fancy. Just displays the view, when user clicks Google Sign-in button and completes the login, it will be notified through KVO that login has completed. At which point, it calls [self dismissViewControllerAnimated:YES completion:nil]; to dismiss itself and tab view controller will be shown
I have attached screen shots to https://drive.google.com/folderview?id=0B1PZ4somNxNtNGkzZzY2cXYwU1U&usp=sharing
with 1. Main.Storyboard and Preview screen of iPhone and iPad showing that iPad shows nothing while iPhone shows the view
Settings of various menus associated with ViewController
How the login screen shows up in the simulator
回答1:
It seems that you add your views not in wAny hAny mode (bottom side in your storyboard). If you add your views in wRegular hRegular (for example) mode you will see your views only on iPads. And vice-verse. Check your view, On bottom of Attributes inspector you probably see something like this
To solve this you can check Installed
and your view will be installed on all size classes.
Read this tutorial, it is good place to start.
来源:https://stackoverflow.com/questions/33979387/view-not-showing-up-in-ipad-only-in-iphone