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……
谢谢:)
发布于 2013-04-10 03:09:20
验证以下内容
1) numberOfRowsInSection中返回值:应为self.listingArray count;
2) RunTimeArray计数应始终为>=2。
https://stackoverflow.com/questions/15914626
复制相似问题