iphone - iOS - 导航标题未更新

标签 iphone ios uinavigationcontroller

我用这段代码做的是抓取一个图像序列,抓取它的名字。然后将 View 的标题设置为播放序列的序列名称,然后将标题设置回旧标题。

问题是导航栏上的标题似乎没有改变。 NSLogs 正在输出正确的值。

我记得以前遇到过这个问题并用一些“刷新”方法解决了它。

这是相关的代码。

-(void)playSequence
{
 if (([animatorViewController isAnimating] == FALSE) && (btnDisable == FALSE))
 {
  Sequence *tempSequence;
  tempSequence = [fullStepList objectAtIndex:lastPlayedSequence];
  self.title = [NSString stringWithFormat:@"Assembly - %@", tempSequence.subName];
  NSLog(self.title);
  [self startAnimator:tempSequence.imageNameScheme forNumFrames:tempSequence.numberOfFrames playInReverse:FALSE];
  tempSequence = nil;
  tempSequence = [fullStepList objectAtIndex:queuedSequence];
  self.title = [NSString stringWithFormat:@"Assembly - %@", tempSequence.subName];
  NSLog(self.title);
  tempSequence = nil;
 }
}

编辑:这种更改标题的方法在此类中的其他位置起作用。当尝试设置它两次导致问题时,问题似乎出现了。

EDIT2:它实际上是一个接一个地运行两个标题更改......事实上将它设置回以前的状态让我失望。

最佳答案

一个导航项可能包含四个内容:leftBarButtonItem、rightBarButtonItem、title 和 titleView。当您需要更改标题时,您应该将标题分配给 navigationItem 的 title 属性,而不是 View 的 title 属性。所以它看起来像:

self.navigationItem.title = [NSString stringWithFormat:@"Assembly - %@", tempSequence.subName];

self.title 指向未显示在导航栏中的 viewControllers 标题。

关于iphone - iOS - 导航标题未更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7248460/

相关文章:

iphone - 指定图像到 4 英寸 iOS 设备

iphone - 无法获得支持的界面方向数组,为什么?

iphone - 在 iOS 上使用动画从右到左调整 View 大小

ios - Apple 以不支持 ipv6 为由拒绝了我们的 phonegap 应用程序

ios - 状态栏出现在标题图像上

iphone - 开发人员向我发送了 .ipa 文件,没有任何其他信息。如何将其上传到 AppStore?

ios - 内存不规则增加只发生在 iPhone XS Max 上

ios - AB地址簿崩溃 CFStringRef

iphone - 如何在 UINavigationController 中的所有 View 前面显示一个 UIButton?

ios - Storyboard 中 UINavigationController 的弹出窗口大小