我想在我的tableview每行上有兩個數據。 喜歡的東西最近調用(左邊的名字,右邊的一天)UITableview每行兩個數據
這是我的代碼:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
//cell.selectionStyle = UITableViewCellStyleValue1 ;
}
// Configure the cell.
NSDictionary *dictionary = [listaOggetti objectAtIndex:indexPath.section];
NSArray *array = [dictionary objectForKey:@"Elementi"];
NSString *cellValue = [array objectAtIndex:indexPath.row];
NSArray *array1 = [dictionary objectForKey:@"Tipo"];
NSString *cellDetail = [array1 objectAtIndex:indexPath.row];
if ([indexPath row] == 0){
cell.textLabel.text = cellValue;
cell.textAlignment = UITextAlignmentCenter;
cell.backgroundColor = [UIColor blueColor];
cell.font = [UIFont systemFontOfSize:13];
} else {
cell.textLabel.text = cellDetail;
cell.detailTextLabel.text = cellValue;
}
return cell;
}
我已經嘗試上使用不同的風格
initWithStyle
沒有任何結果(只顯示我的詳細信息在右邊)。 在NSLOG中,我看到了cellDetail的正確值。
{
Elementi = (
"Chiamate e Videochiamate Nazionali",
"08m:43s",
"1h:31m:17s",
"1h:40m:00s"
);
},
{
Tipo = (
Effettuato,
Rimanente,
Totale
);
},
{
Elementi = (
"SMS e MMS Nazionali",
21,
29,
50
);
},
{
Tipo = (
Effettuato,
Rimanente,
Totale
);
},
{
Elementi = (
"Traffico Dati FMM",
"69.95 MB",
"954.05 MB",
"1024.00 MB"
);
},
{
Tipo = (
Effettuato,
Rimanente,
Totale
);
},
{
Elementi = (
Skype,
"00m:00s",
"3h:20m:00s",
"3h:20m:00s"
);
},
{
Tipo = (
Effettuato,
Rimanente,
Totale
);
},
{
Elementi = (
"WWW3, Yahoo!, Google, eBay e altri servizi",
"0.00 MB",
"100.00 MB",
"100.00 MB"
);
},
{
Tipo = (
Effettuato,
Rimanente,
Totale
);
}
)
我的目標是獲得細胞是這樣的:
`dequeueReusableCellWithIdentifier`返回一個指向一個可重複使用的單元格或零,而他之後和allocs檢查零如果合適 – 2010-12-06 14:55:20
@Luke Mcneice我相信初始化細胞 – 2010-12-06 15:01:26
OK,用於校正感謝時,他使用了錯誤的風格 – 2010-12-06 15:09:09