【发布时间】:2011-03-31 21:34:57
【问题描述】:
亲爱的 我试图在一个 tableView 中显示两个不同的数组。 我将“years”数组声明为字符串,将“amount”数组声明为整数。 年金额 例如:2012、2013 .... 155888、151768 当我 build7run 应用程序时,结果如下: (看起来它减少了 16 个数字)
Remaining Amount On
2012: 80912864
2013: 79047056
2014: 79046640
2015: 79046640
2016年:79051632
...
2020:80928544
“year”数组作为字符串工作,但作为“amount”的整数数组却没有。 我很确定我在整数格式的 cell.text= 行中做错了。 如果你能帮助解决这个问题,我会很高兴 提前致谢
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"remainingAmountOn";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
NSUInteger row = [indexPath row];
**cell.text =** [NSString stringWithFormat:@"%@ %d", [years objectAtIndex:row],
[NSNumber numberWithInt:[amount objectAtIndex:row]]];
return cell;
}
【问题讨论】:
标签: objective-c uitableview row nsindexpath nsuinteger