TabBarController をビューにプッシュするにはどうすればよいですか?
アプリはビューベースです。アプリには、TabBarController を持つ XIB があり、TabBar をディスプレイにプッシュしたいと考えています。私はすべてをやりましたが、何が間違っているのかわかりません。
TabBarController をプッシュするコードは次のとおりです。
- (void)showTabBar {
TabBar *tbc = [[TabBar alloc] initWithNibName:@"TabBar" bundle:nil];
[self presentModalViewController:tbc animated:YES];
[tbc release];
}
この時点で、XIB には空のビューがあります。したがって、このコードを実行するとディスプレイは白くなります。ディスプレイに表示したい TabBarController もあります。
ご協力いただきありがとうございます。
アップデート:
これらは2つの異なるクラスであると言わざるを得ません。関数「showTabBar」のベースとなるクラスは、TabBarController をプッシュする必要があります。2 番目のクラスは TabBar です。TabBar は、TabBarController のデリゲートです。
だから私はこのように答えを修正しましたが、私は両方を試しました:
[self presentModalViewController:tbc.tabBarController.view animated:YES];
エラーは次のようになります。
Incompatible Objective-C types 'struct UIView *', expected 'struct UIViewController *' when passing argument 1 of 'presentModalViewController:animated:' from distinct Objective-C type
アップデート:
おや、エラーが消えました。涼しい。;)
しかし、アプリは終了しています。以前にこの動作を見たことがありますが、どうすればよいかわかりませんでした。デバッガー コンソールには次のように表示されます。
2011-01-27 15:49:32.629 Touch[3657:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target <StartUp: 0x9300f20>.'