0

ツールバー付きのナビゲーション バー コントローラーがあります。ツールバーの左隅にあるボタンは 1 つだけです: 情報ライト。ビューを横向きに回転すると、ツールバーは表示されたままですが、ボタンが表示されなくなります。

どうすればそれを維持できますか。IB でツールバーのストラットを確認しました。これらは、ツールバーの左下隅に留まるように設定されています。

ベース SDK が 4.0 の iPod touch でテストしています。

コードは次のとおりです。

UIButton *info = [UIButton buttonWithType:UIButtonTypeInfoLight];
[info addTarget:self 
             action:@selector(infoTap:) 
   forControlEvents:UIControlEventTouchUpInside];
/** Allocate and initialize the information button on the leftside of the toolbar.
 */
UIBarButtonItem *infoItem = [[UIBarButtonItem alloc] initWithCustomView:info];
/** Use this to put space in before your info toolbar button.
   */
UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
/** Add buttons to the array.
   */
NSMutableArray *items = [NSMutableArray arrayWithObjects: infoItem, flexItem, nil];
/** Add array of buttons to toolbar.
   */
[self.toolbar setItems:items animated:NO];
/** Add the toolbar as a subview to the navigation controller.
   */
[self.navigationController.view addSubview:toolbar];

助言がありますか?

アマンダ

4

1 に答える 1

0

あなたが投稿したコードはあなたがやりたいことに対して正しいので、問題はサポートコードにあります。

私がチェックするいくつかのこと:囲んでいるビュー(self.navigationController.view)は回転時にサイズ変更されていますか?

self.navigationController.viewの支柱と自動サイズ変更マスクとは何ですか?

UIToolbarの支柱と自動サイズ変更マスクとは何ですか?

(「IBでツールバーの支柱を確認しました。ツールバーの左下隅にとどまるように設定されています。」とはどういう意味かわかりません。ツールバーをツールバーの左下にとどめるにはどうすればよいですか。 )。

于 2012-06-23T01:17:19.513 に答える