小编rya*_*ang的帖子

如何处理iOS 11导航BarButtonItems错误?

UINavigationBar在iOS 11中发现了一个错误.在viewDidLoad中使用了快速设置导航项按钮self.navigationItem.rightBarButtonItems = @[fixSpaceItem, item].并且使用手势回弹,但是我没有回弹,当弹出回来时,我释放我的手指并让视图控制器取消弹回,然后右侧导航按钮项目消失.左项按钮具有相同的问题.要重现此错误,您必须添加fixSpaceItem [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil].而真正的设备,但不是模拟器可以重现错误.这是我的主要代码:

- (void)viewDidLoad {
    [super viewDidLoad];

    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;

    self.navigationItem.rightBarButtonItems = @[[self negativeSpacerWithWidth:5],[self rightButton]];
    self.navigationItem.leftBarButtonItems = @[[self negativeSpacerWithWidth:5], [self leftButton]];

}

- (UIBarButtonItem *)leftButton {
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
    [button setImage:[UIImage imageNamed:@"icon_app_back_normal"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:button];
    return item;
}

- (UIBarButtonItem *)rightButton {
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 35, …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios ios11

7
推荐指数
1
解决办法
6045
查看次数

标签 统计

ios ×1

ios11 ×1

iphone ×1

objective-c ×1