0

Gday,试图将我的循环 tableview 数组拆分为它自己的静态数组,然后在 UITableView 中的每个标签上使用它......

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ListingCell";

UITableViewCell *cell = [tableView
                         dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc]
            initWithStyle:UITableViewCellStyleDefault
            reuseIdentifier:CellIdentifier];
}

//Load Row Value into NSArray
NSString *RowValues = [self.ListingArray objectAtIndex:[indexPath row]];
NSArray *RunTimeArray = [RowValues componentsSeparatedByString:@","];


//Configure the cell.
cell.detailTextLabel.text = [RunTimeArray objectAtIndex:1]; //small label
cell.textLabel.text = [RunTimeArray objectAtIndex:0]; //main title

return cell;
}

当我运行项目时,它返回一个错误:

DATE APP_NAME[28399:c07] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'

基本上这意味着 Index :1 不存在,但 Index:0 确实...当我重新加入数组时,例如 '-------' 它都显示正确,因此它的含义是新对象具有不同索引到 1 或另一个连续数字。

知道如何使它们成为连续索引,例如:0,1,2,3,4 而不是 0,21581,2185929,385749 ...

谢谢 :)

4

1 回答 1

0

验证以下内容

1) numberOfRowsInSection:中返回的值应该是[self.listingArray count];

2) RunTimeArray 计数应始终 >=2。

于 2013-04-10T03:09:20.437 回答