【发布时间】:2016-11-05 18:03:35
【问题描述】:
我正在构建一个通用 iOS 应用程序。 我在主视图上有几个按钮可以加载其他视图控制器。 我已经设置了一个“Main.storyboard”和一个“iPad storyboard.storyboard”。 我在“主要”和“iPad”中提出了两个观点。 在“Main”上,我将 Storyboard ID 设置为“FirstCar”和“FirstPlayer”。 在“iPad”上,我将它们设置为“FirstCarPad”和“FirstPlayerPad”。 在常规设置中,我将应用程序指定为通用,并将“主”设置为 iPhone 的情节提要,将“iPad”设置为 iPad。
我正在使用以下代码从初始视图启动情节提要中的视图控制器。
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
int height = [UIScreen mainScreen].bounds.size.height;
if (height == 568.0) {
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"FirstCar"];
[self presentViewController:vc animated:YES completion:NULL]; }
}
else if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad){
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"ipad storyboard" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"FirstCarPad"];
[self presentViewController:vc animated:YES completion:NULL]; }
当我点击访问“FirstCar”和“FirstCarPad”的第一个按钮时 ViewControllers 一切正常,但是 当我点击访问“FirstPlayer”和“FirstPlayerPad”的第二个按钮时 viewControllers 应用程序因此崩溃
由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“Storyboard () 不包含标识符为“FirstPlayerPad”的视图控制器”
但我的 viewControllers 设置与 Storyboard ID 完全相同
我要把头发扯下来。
谁能帮帮我。
【问题讨论】:
-
如果您可以针对 iOS 8+,请考虑使用一个情节提要和大小类。
-
我可以访问大小 iOS 8+,但是当我使用自动布局时,我的应用程序无法正常工作。我正在使用运动管理器,它会不断重置事物,以便在我移动对象时将其返回到原始位置。不过我不认为这应该那么难。
标签: objective-c uiviewcontroller xcode7 xcode-storyboard ios-universal-app