Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ナビゲーション バーを備えたモーダル ポップアップ ビューがあり、ステートメントを使用して、現在読み込まれているビューからそのナビゲーション バーの高さにアクセスしようとすると...
self.navigationController.navigationBar.frame.size.height;
...それは 0 を返します。なぜでしょうか?
あなたの知恵を前もってどうもありがとう!
おそらく、式で使用しているオブジェクトの 1 つが であるためですnil。
nil
これはおそらくself.navigationControllerそれ自体です。ビュー階層を誤解している可能性がありますか? (NSLog(@"%@", self.navigationController);そうであるかどうかを確認してみてくださいnil)
self.navigationController
NSLog(@"%@", self.navigationController);
理由はわかりませんが、何も変更しない場合、ナビゲーション バーの高さは常に 44 ピクセルになります。