【问题标题】:UITabBarItem setBadgeValue:nil throws EXC_BAD_ACCESSUITabBarItem setBadgeValue:nil 抛出 EXC_BAD_ACCESS
【发布时间】:2015-02-17 12:25:01
【问题描述】:

我有一个标签栏,我试图通过将其设置为nil 来删除项目的徽章值。但是,有时,我会收到 EXC_BAD_ACCESS 错误。异常后主线程挂起,我poing:

(lldb) po [[self.tabBar items] objectAtIndex:2]
<UITabBarItem: 0x17015e980> //no problem with the class itself

(lldb) po [[[self.tabBar items] objectAtIndex:2] setBadgeValue:0]
 nil

(lldb) po [[[self.tabBar items] objectAtIndex:2] setBadgeValue:1]
error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0x1).
The process has been returned to the state before expression evaluation.

(lldb) po [[[self.tabBar items] objectAtIndex:2] setBadgeValue:0]
 nil

这似乎是随机发生的,至少我还没有找到特定的模式。但是,这没有任何意义。这是一个错误吗?

更新:糟糕,我尝试在上面的调试器中设置数字而不是字符串,在上面抛出异常是正常的,但原来的问题仍然存在。

【问题讨论】:

  • nilbadgeValue 根据文档的默认值。所以原因一定是在别的地方……你说你传递了一个有效的字符串?

标签: ios objective-c uitabbarcontroller uitabbar uitabbaritem


【解决方案1】:

你应该使用

[[self navigationController] tabBarItem].badgeValue = @"your-value";

Here is the link for your reference

【讨论】:

  • 但我不能。这不是我设置的当前选择的标签栏项目。
猜你喜欢
  • 2014-10-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多