ViewController
Xcode を使用して iOS で簡単なアプリを作成しています。別のアプリをモーダルとして読み込もうとしています。モーダルをロードしているオリジンHomeScreenViewController
(から継承) は、プロジェクトのストーリーボードに由来します。
次に、ボタンが押されたイベントへの応答として、このモーダルを次のようにロードします。UIViewController
-(IBAction)onAddButtonPressed:(UIButton *)sender {
MyAnotherViewController *vc = [[MyAnotherViewController alloc] init];
[self presentViewController:vc animated:YES completion:nil];
}
このクラスMyAnotherViewController
は、ナビゲーション バーとテキスト フィールドを表示する単純なクラスであるため、ストーリーボードには表示されません。コードは次のとおりです (部分的なコード、残りは Xcode の自動生成メソッドです):
@implementation MyAnotherViewController
- (void)viewDidLoad {
[self.navigationItem setTitle:@"Example"];
[self.view addSubview:[[UITextView alloc]initWithFrame:self.view.bounds]];
}
@end
navigationItem
問題は、何らかの理由で が表示されないことです (添付の画像でも確認できます) 。私はそれがそうではない
ことも検証しました。さらに、タイトルが実際に「Example」に設定されていることをデバッグ モードで確認できます。self.navigationItem
nil
あなたの助けは大歓迎です、
乾杯...