我在 X-Code 中启动了一个主从应用程序。我选择了通用、核心数据和 git repo 选项。当应用程序出现时,我进入 iphone 故事板,添加了一个选项卡视图控制器,将它开始的导航/表格/详细信息视图移动到选项卡控制器中作为第三个选项卡(实际上我希望它是第四)。然后我选择选项卡控制器作为程序在 iphone 模式下应启动的初始视图。它构建成功,但不允许程序完成加载。出现的错误记录如下:
2013-05-11 21:35:00.302 FearlessAndThorough[6318:907] -[UITabBarController topViewController]: unrecognized selector sent to instance 0x1c592020
2013-05-11 21:35:00.306 FearlessAndThorough[6318:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITabBarController topViewController]: unrecognized selector sent to instance 0x1c592020'
*** First throw call stack:
(0x337f33e7 0x3b4ee963 0x337f6f31 0x337f564d 0x3374d208 0xc9e43 0x35662aa1 0x35662625 0x3565a833 0x35602d1f 0x356027ad 0x356021ef 0x3731a5f7 0x3731a227 0x337c83e7 0x337c838b 0x337c720f 0x3373a23d 0x3373a0c9 0x3565946d 0x356562b9 0xc9ab5 0x3b91bb20)
libc++abi.dylib: terminate called throwing an exception
(lldb)
我希望有人以前做过这件事,并且可以让我了解在设置选项卡视图控制器类型应用程序时要采取的正确程序或步骤,然后将其转换为 ipad 的主详细信息应用程序。
这是当前应用程序委托的 didFinishLaunchingWithOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
splitViewController.delegate = (id)navigationController.topViewController;
UINavigationController *masterNavigationController = splitViewController.viewControllers[0];
MasterViewController *controller = (MasterViewController *)masterNavigationController.topViewController;
controller.managedObjectContext = self.managedObjectContext;
} else {
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
MasterViewController *controller = (MasterViewController *)navigationController.topViewController;
controller.managedObjectContext = self.managedObjectContext;
}
return YES;
}