私は iPad アプリケーションを持っており、画面の 1 つに のとして設定UIToolbarしています。私も と を持っています。titleViewviewControllernavigationItemleft-rightBarButtonItem
横向きで画面に入ってデバイスを回転させると、titleView中央に残ります。ただし、反対のことをすると(縦向きで入力してデバイスを回転させる)、titleViewが右にずれます。これを修正する方法はありますか?これが私のコードです:
UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 350, self.navigationController.navigationBar.frame.size.height)];
UIToolbar *titleToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 350, self.navigationController.navigationBar.frame.size.height)];
titleToolbar.items = @[commentButton, spacer2, downloadButton, spacer3, homeButton, spacer4, pageDisplayButton, spacer5, searchButton];
titleToolbar.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[titleView addSubview:titleToolbar];
self.navigationItem.titleView = titleView;
編集:
どちらのself.navigationItem.titleView.frame.sizeシナリオでも同じですが、変更点はorigin.x