UITableView indexPath null问题

时间:2011-11-13 01:21:52

标签: objective-c xcode uitableview uiviewcontroller

我的UITableView存在此问题。当我拖动表格以使底行向上一半时,我会崩溃。当我基本上拖动底行时,我可以得到它。代码段如下:

- (UITableViewCell *)tableView:(UITableView *)tableView 
         cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }


    NSString *section = [[browseCategoriesDictionary allKeys] objectAtIndex:indexPath.section];
    NSArray *objectsForSection = [browseCategoriesDictionary objectForKey:section];

    NSString *cellValue = [objectsForSection objectAtIndex:indexPath.row];
    cell.textLabel.text = cellValue;
    cell.backgroundColor = [UIColor colorWithRed:0x7C/255.0 green:0x7E/255.0 blue:0xBB/255.0 alpha:1];
    cell.detailTextLabel.numberOfLines = 3;
    cell.detailTextLabel.textColor = [UIColor whiteColor];


    cell.detailTextLabel.text = [cellDescriptions objectAtIndex:indexPath.row];
    cell.imageView.image = [UIImage imageNamed:[cellIcons objectAtIndex:indexPath.row]];

    return cell;
}

谢谢你们

1 个答案:

答案 0 :(得分:0)

请检查您使用的不同数据源是否未返回nil值,否则可能会导致崩溃。