开发者

Removing UIBarButtonItem from UIToolBar

开发者 https://www.devze.com 2023-03-21 02:48 出处:网络
I have a UIToolBar that is created in XCode.In it, there is a UISegmentControl.Based on when one action is pressed, a new view is added as a subView that has a UIToolBar, but without the UISegmentCont

I have a UIToolBar that is created in XCode. In it, there is a UISegmentControl. Based on when one action is pressed, a new view is added as a subView that has a UIToolBar, but without the UISegmentControl. On this view, I add a UIBarButtonItem to go back that looks like this:

UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(GoBack)];
NSArray *barItems = [NSArray arrayWithObject:backButton];
[self.MainToolbar setItems:barItems];
[backButton release];

How do I remove this UIBarButtonItem once my selector(GoBack) is called? I assume I put the code in that method to remove the UIBarButtonItem. I tried this, but it did not work.

[self.MainToolbar setItems:[NSArray arrayWithObje开发者_运维知识库ct:nil]];

I wasn't sure how to remove it, and how or if this affects the UISegmentControl that is in the UIToolBar created in the .xib.

I have seen code about using the navigationItem, but I'm not sure how the UIToolBar relates to the navigationItem as well. Thanks!

0

精彩评论

暂无评论...
验证码 换一张
取 消