Iphone 从可变数组加载tableview

Iphone 从可变数组加载tableview,iphone,Iphone,大家好,我在将字符串数组加载到tableview时遇到了麻烦,我已经做的是解析信息并将所需数据存储到名为States1的可变元素数组中,现在我要做的是使用customize lable将States1加载到table view中,以便用户可以看到所有值,现在我的问题是,当我加载表视图时,它会给出一个错误,请帮我解决这个问题 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexP

大家好,我在将字符串数组加载到tableview时遇到了麻烦,我已经做的是解析信息并将所需数据存储到名为States1的可变元素数组中,现在我要做的是使用customize lable将States1加载到table view中,以便用户可以看到所有值,现在我的问题是,当我加载表视图时,它会给出一个错误,请帮我解决这个问题

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

    int counter=indexPath.row;

    NSString *CellIdentifier = [NSString stringWithFormat:@"%d",counter];

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

        UIImageView *imgViewBack=[[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 100.0)];
        imgViewBack.image=[UIImage imageNamed:@"black-_image.png"];
        [cell.contentView addSubview:imgViewBack];

        if(statuses1)
        {
            UILabel *lblTitle=[[UILabel alloc] initWithFrame:CGRectMake(100.0, 10.0, 200.0, 20.0)];
            lblTitle.text=[statuses1 objectAtIndex:indexPath.row];
            [cell.contentView addSubview:lblTitle];
            [lblTitle release];
        }                           
        //[cell.contentView addSubview:btnRowButton];
    }               
    return cell;
}

不必为每个单元格添加新的标签视图,您可以

cell.detailTextLabel.text = [statuses1 objectAtIndex:indexPath.row];

我不确定,但之后的版本可能会导致错误。您只需查看回溯,看看您是否能够找出是哪个调用导致了它。带有bug的黄色小按钮

OP释放lblTitle是合适的,因为他正在调用alloc/init。但是我必须在表视图上显示几个标签,所以我必须对其进行自定义。当应用上述结果时,给出了不好的结果EXCESS@Jacob你说得对@普拉什,你有没有试着查看追踪结果?当应用程序运行时,它是Shift-Command-Y。cell.detailTextLabel.text在每个单元格中都有效,因此它应该适用于您的目的。