我有一个 tabBarApplication 作为模板,每个选项卡上都有一个 UINavigation 模板。
我想使用该示例(有点)并将其转换为另一个应用程序中的单个 UIViewController。我已经展示了 2 段代码,第一个是我的模板,后者是我正在尝试制作的。谁能给我一些提示或帮助如何做到这一点?我不断收到错误,但它们对我来说没有意义,因为 tabBarApp 不需要它声明的 viewController。
第一个代码(示例):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self setupFetchedResultsController];
if (![[self.fetchedResultsController fetchedObjects] count] > 0 ) {
NSLog(@"!!!!! ~~> There's nothing in the database so defaults will be inserted");
[self importCoreDataDefaultRoles];
}
else {
NSLog(@"There's stuff in the database so skipping the import of default data");
}
// The Tab Bar
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
// The Two Navigation Controllers attached to the Tab Bar (At Tab Bar Indexes 0 and 1)
UINavigationController *personsTVCnav = [[tabBarController viewControllers] objectAtIndex:0];
UINavigationController *rolesTVCnav = [[tabBarController viewControllers] objectAtIndex:1];
return YES;
}
第二个代码(我想要做的):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self setupFetchedResultsController];
if (![[self.fetchedResultsController fetchedObjects] count] > 0 ) {
NSLog(@"!!!!! ~~> There's nothing in the database so defaults will be inserted");
[self importCoreDataDefaultRoles];
}
else {
UIViewController *mainViewController = (UIViewController *)self.window.rootViewController;
UINavigationController *readingsTVCnav = [[mainViewController viewController] objectAtIndex:0];
// Override point for customization after application launch.
return YES;
}
代码的获取部分与已经设置和工作的核心数据相关。此更改的原因是我希望将普通视图控制器设置为初始屏幕而不是 tabBarConfiguration。
干杯杰夫
编辑:为了清楚起见,我添加了一张图片