我想在UITableViewCell上設置字幕標籤。我有一個包含標題和副標題對的字典,密鑰列表存儲在self.results中。但是,當我運行以下代碼:DetailTextLabel行爲奇怪
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Search Result Cell" forIndexPath:indexPath];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Search Result Cell"];
}
cell.textLabel.text = [self.results objectAtIndex:indexPath.row];
cell.detailTextLabel.text = self.resultPairs[[self.results objectAtIndex:indexPath.row]];
NSLog(@"%@", self.resultPairs[cell.textLabel.text]);
字幕保持空白,但NSLog打印正確的輸出。這裏發生了什麼?當我將detailTextLabel設置爲常量時,它工作正常。
你是如何獲得'細胞'的? – FlyingPiMonster 2014-12-06 13:08:16
我會編輯問題,但標題設置正確,所以我知道我有正確的單元格。 – stmfunk 2014-12-06 13:08:53
確保self.resultPairs [[self.results objectAtIndex:indexPath.row]]不爲零。 – Mat 2014-12-06 13:15:12