Hide UIToolbar UIBarButtonItems

后端 未结 6 1502
[愿得一人]
[愿得一人] 2020-12-03 08:12

I have a UIToolbar that I set up using IB with three buttons, left, middle and right. In some situations I would like to not display the middle button. Does anybody know of

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-03 08:45

    This does not work here because the array you are sending with setItem is not what the function expects.

    I had to replace the line:

    NSArray *finalTabBarArray = [[NSArray alloc] initWithObjects:newToolBarArray, nil];
    

    with this one:

    NSArray *finalTabBarArray = [newToolBarArray copy];
    

    Then it works perfectly.

提交回复
热议问题