我有这个:
当我旋转时,图标完全没有了(他们不像在< 11中那样调整大小和重新定位):
这就是我实现代码的方式。我将UINavigationBars
与UIBarButtonItem
设置为自定义图片,如下所示:
- (void) loadNavigationBarButton:(UIBarButtonItem*)navigationBarButton withSpacerWidth:(CGFloat)spacerWidth barButtonDirection:(CGFloat)barButtonDirection
{
NSArray* items = @[navigationBarButton];
if (barButtonDirection == 0)
{
[self.navigationItem setLeftBarButtonItems:items animated:NO];
}
else
{
[self.navigationItem setRightBarButtonItems:items animated:NO];
}
}
这就是我初始化其中一个UIBarButtonItems
:
- (void) loadDefaultRightButton
{
ButtonView *rightButtonView = [[ButtonView alloc] initWithFrame:CGRectMake(0, 0, 60.71090047393365, 44) image:[[[NextButtonIcon alloc] initWithHighlight:NO] imageForSize:CGSizeMake(60.71090047393365, 44)] highlightFrame:CGRectMake(0, 0, 60.71090047393365, 44) highlightImage:[[[NextButtonIcon alloc] initWithHighlight:YES] imageForSize:CGSizeMake(60.71090047393365, 44)] highlightOnTop:YES buttonViewType:ButtonViewTypeNext roundedCorners:NO enableDisabledView: NO doubleTap:NO singleTapGestureRecognizer:nil];
rightButtonView.delegate = self;
[rightButtonView.widthAnchor constraintEqualToConstant: 60.71090047393365].active = YES;
[rightButtonView.heightAnchor constraintEqualToConstant: 44].active = YES;
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithCustomView:rightButtonView];
[self loadNavigationBarButton:rightButton withSpacerWidth:21 barButtonDirection:1];
}
由于某种原因,当我旋转到横向时,UIBarButtonItems
不会像过去那样调整自己的大小。它们保持大而且溢出屏幕。有谁知道为什么会这样?我的UIViewControllers
占据了全屏fwiw。
更新:添加了图片和其他澄清评论。