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 ...
谢谢 :)