Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 重新加载导航栏_Ios_Navigation_Uinavigationbar_Uinavigationitem - Fatal编程技术网

Ios 重新加载导航栏

Ios 重新加载导航栏,ios,navigation,uinavigationbar,uinavigationitem,Ios,Navigation,Uinavigationbar,Uinavigationitem,如何重新加载/分配导航栏项目?我使用一些库来更改导航栏,有时我有一个包,其中所有导航项都消失了。我已在视图中重新分配了正确的项,这些项将显示如下: UIButton *actionButton = [UIButton buttonWithType:UIButtonTypeCustom]; actionButton.frame = CGRectMake(270, 0, 50, 50); actionButton.adjustsImageWhenHighlighted = YES; [actionB

如何重新加载/分配导航栏项目?我使用一些库来更改导航栏,有时我有一个包,其中所有导航项都消失了。我已在
视图中重新分配了正确的项,这些项将显示如下:

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;
但它不工作,有时我没有任何导航项目

UIBarButtonItem
不是UIButton的子级

这里没有已知的方法,如
setImage:forState:

创建并保存一个像这样的Uitabbutton

UIBarButtonItem *newBackButton = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleBordered target:self action:@selector(goBack)];
    newBackButton.image = [UIImage imageNamed:@"back"];
    self.navigationItem.leftBarButtonItem=newBackButton;
还要验证当
viewdiload

查看这篇文章时,是否会调用带有此代码的方法,就像苹果开发人员非常棒一样

这是另一个很好的链接 AppCoda有很多很棒的教程,这本教程包含了关于导航条的所有知识


您还可以使用perform segue with identifier方法,向新的视图控制器发送一个字符串或其他内容,然后当您看到该字符串等于所需的值时,在ViewWillDisplay方法中使用if语句。

您使用的是什么库?您需要找出库在什么时候扰乱了您的工具栏,然后调用您的代码,或者阻止它发生GamScrollingNavBar,它的开发人员不知道发生了什么=/好的,您的问题中的一些信息丢失了。你说的包是什么意思?如何将视图控制器和导航控制器连接起来(假设使用了一个故事板)?我不认为库有错,因为它没有在任何地方设置barButtonItems。