各タブに UINavigation テンプレートを持つテンプレートとして持っている tabBarApplication がありました。
そのサンプル (一種) を使用して、別のアプリケーションで単一の 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;
}
2番目のコード(私が作ろうとしているもの):
- (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;
}
コードの取得部分は、既にセットアップされて動作している Core Data に関連しています。この変更の理由は、最初の画面として、tabBarConfiguration ではなくプレーン ビュー コントローラーを設定したいからです。
乾杯ジェフ
編集:わかりやすくするために画像を追加しました