我試圖檢索顯示指定選項卡的值。它之前在工作,並因某種原因停止了?下面的代碼中的int current_badge =
行是獲取徽章值並返回零的位置,而不管徽章實際值是什麼。我處於一個視圖控制器,它被一個uitabcontroller隔離。任何人有任何想法我做錯了什麼?iOS - 從選項卡中檢索到不正確的徽章值
更新:這似乎是因爲我在一個tab控制器的viewcontroller。將相同的代碼移動到標籤視圖控制器中,並且工作正常。有沒有更好的方法來確定標籤控制器中的徽章值時,它被找出來了嗎?
-(void)badgeUpdate:(int)tab:(int)dayspan
{
// getting the current badge amount
int current_badge = [[[super.tabBarController.viewControllers objectAtIndex:tab] tabBarItem].badgeValue intValue];
// testing for badge level
if (current_badge > 0)
{
// testing for updates on tab for dayspan or longer
int updates_waiting = [self updatesWaitingCheck:tab:dayspan];
if (updates_waiting > 0)
{
// setting new badge level on tab
[[[[[self tabBarController] viewControllers] objectAtIndex:tab] tabBarItem] setBadgeValue:[NSString stringWithFormat:@"%d", updates_waiting]];
}
else
{
// turning off badge display
[[[[[self tabBarController] viewControllers] objectAtIndex:tab] tabBarItem] setBadgeValue:nil];
}
}
}
這不是一個xcode問題,它是一個iOS問題,所以我更改了標籤和標題。 – 2013-03-03 17:04:52
感謝您的更正 – Grymjack 2013-03-03 17:16:06