ツールバー付きのナビゲーション バー コントローラーがあります。ツールバーの左隅にあるボタンは 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];
助言がありますか?
アマンダ