【发布时间】:2014-05-26 20:10:19
【问题描述】:
如何重新加载/重新分配导航栏项目?我使用一些更改导航栏的库,有时我有一个包,其中所有导航项都消失了。我在viewWillAppear 中重新分配了正确的项目,例如:
UIButton *actionButton = [UIButton buttonWithType:UIButtonTypeCustom];
actionButton.frame = CGRectMake(270, 0, 50, 50);
actionButton.adjustsImageWhenHighlighted = YES;
[actionButton setImage:[UIImage imageNamed:@"share.png"] forState:UIControlStateNormal];
[actionButton setImage:[UIImage imageNamed:@"share-active.png"] forState:UIControlStateHighlighted];
[actionButton addTarget:self action:@selector(presentActivity) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *actionBarButton = [[UIBarButtonItem alloc]initWithCustomView:actionButton];
actionBarButton.tintColor = [UIColor whiteColor];
self.navigationItem.rightBarButtonItem = actionBarButton;
但它不起作用,有时我没有任何导航项。
【问题讨论】:
-
你用的是什么库?您需要找出库在什么时候弄乱了您的工具栏,然后调用您的代码或阻止它发生
-
AMScrollingNavbar,它的开发者不知道会发生这种情况=/
-
好的,您的问题中缺少一些信息。 包是什么意思?您如何将视图控制器与导航控制器连接起来(假设正在使用一个情节提要)?
-
我不认为该库有问题,因为它没有在任何地方设置 barButtonItems。
标签: ios navigation uinavigationbar uinavigationitem