tags:

views:

52

answers:

1

i did this but still if i scroll table with force data are shuffling

  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
        //  
        //cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle   reuseIdentifier:CellIdentifier] autorelease];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        XMLAppDelegate *appDelegate=(XMLAppDelegate*)[UIApplication sharedApplication].delegate;
        DetailXml   *aDetail=[appDelegate.dxml objectAtIndex:indexPath.row];

                        switch(indexPath.section)
        {


            case 0:



                NSLog(@" cell 1");


                {
                    CGRect frame;
                    frame.origin.x = 70; 
                    frame.origin.y = 15;
                    frame.size.height = 25;
                    frame.size.width = 320;

                    cLabel = [[UILabel alloc] initWithFrame:frame];
                    cLabel.textColor = [UIColor blackColor];

                    //[label setFont:[UIFont fontWithName:@"Helvetica-Bold" size:16]];
                    [cLabel setFont:[UIFont fontWithName:@"Verdana-Italic" size:14]];
                    cLabel.tag = Ca;
                    [cell.contentView addSubview:cLabel];
                    [cLabel release];
                    cLabel.backgroundColor = [UIColor clearColor];
                                        cLabel.text = [NSString stringWithFormat:@"%@", aDetail.telnumber];


                    cLabel.backgroundColor = [UIColor clearColor];


                    cell.backgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"r1.png"]] autorelease];
                    counte=1;
                }
                break;

            case 1:

                {NSLog(@" cell 2");
                    //counte=0;

                    cell.backgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"n1.png"]] autorelease];

                }

                break;
A: 

You Really should cleanup youre code before posting here!

It is very hard to read and you have many errors, whitespace and commented-out-lines in it that you should remove..

Read http://developer.apple.com/iphone/library/documentation/userexperience/conceptual/TableView_iPhone/TableViewCells/TableViewCells.html#//apple_ref/doc/uid/TP40007451-CH7-SW15 It should help you get started with custom cells..

Basically all the customization should go in:

if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
      //Customization here:
}

The way you do it you are allocating labels every time a new cell is displayed instead of reusing..

It seems like youre cells are static. You only have one cell per section and dont need reusing the cells? If so maybe it would be easier to create static cells with interfacebuilder http://developer.apple.com/iphone/library/documentation/userexperience/conceptual/TableView_iPhone/TableViewCells/TableViewCells.html#//apple_ref/doc/uid/TP40007451-CH7-SW32

Larsaronen
so how to deal with static cells??
prajakta
so how to deal with static cells?? if i do that like you said then my same label is replicating in all sections ( this is my section view not row)
prajakta
Read the last link for static cells.. It explains everything about them..Add a tag to the labels you create and set the text of the label outside of the - (cell == nil) method. Please read either of the links i provided. They have sample code with all this..
Larsaronen
alright thanks :-)
prajakta
its not resolved :(
prajakta