tags:

views:

36

answers:

1

hey people im having trouble with loading my array of strings into a tableview , what i have already done is parse information and stored the data i need into an mutablearray of elements called statues1, now what i want to do is load up the statues1 into the table view with customize lable so the user can see all the values , now my problem is that when i load up the table view it gives an error ""BAD EXCESS", Please help me out for this?

- (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;
}
A: 

Instead of adding a new label view for each cell, you can

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

I'm not sure, but that release after that could be causing the error. You just check out hte traceback to see if you can figure out which call caused it (the little yellow button with a bug on it)

Matt Williamson
@Matt, the OP's `release` of `lblTitle` is appropriate as he is calling `alloc/init`.
Jacob Relkin
but i have to show several lables on the table view so i have to customize it. as applying the above result give "BAD EXCESS"
Prash.......
@Jacob, you're right. @Prash, did you try looking at the traceback? (It's Shift-Command-Y while the app is running)
Matt Williamson
BTW. cell.detailTextLabel.text works per cell so it should work for your purposes.
Matt Williamson
yes i have tried for it
Prash.......