Adding uitableview to uitableviewcells issues?

enter image description hereI have one iphone application in which I add a uitableview inside uitableviewcell.in that each uitablecell contains a tableview that has a dynamic row based on user entry.ie the tableview in the first cell contains 3 rows.tableview in seconds the row contains 4 row.thus it vary.my the problem is that when I look at the table view, the entries are repeated. How can I solve this? any tutorial or sample code?

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


    if(tableView==self.tbView)
    {
        UITableView *tb;

    static NSString *CellIdentifier=@"CellIdentifier";

    UITableViewCell *cell1=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        int height;

    if(cell1==nil)
    {

        cell1=[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]autorelease];
        tb=[[[UITableView alloc] initWithFrame:cell1.contentView.frame style:UITableViewStylePlain]autorelease];
        tb.rowHeight=50;
        [cell1.contentView addSubview:tb];

            NSMutableArray *a2=[[NSMutableArray alloc]init];
                a2=[dateArray objectAtIndex:indexPath.row];

        cntt=cntt+1;
            int no=[a2 count]+1;
            height=(no*50);
            heightcnt2=heightcnt2+1;
        NSLog(@"frame of tableviewcontentcell is %@",cell1.contentView.frame);
        tb.frame=CGRectMake(cell1.contentView.frame.origin.x,cell1.contentView.frame.origin.y,cell1.contentView.frame.size.width,height);
        tb.delegate=self;
        tb.dataSource=self;
        tb.tag=tag1;
        tb.scrollEnabled=NO;
        tag1=tag1+1;

    }

        return cell1;


    }   
    else 
    {
        static NSString *CellIdentifier2 = @"Cell";


         CategoryListCustomCell *cell = (CategoryListCustomCell *)[[tableView dequeueReusableCellWithIdentifier:CellIdentifier2]autorelease];
        if (cell == nil) {
            cell = [[[CategoryListCustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier2]autorelease];
        }



        if(indexPath.row==0)
        {
            NSMutableArray *temp=[[NSMutableArray alloc]init];
            int cmp=[dateArray count];
            if(cnt<=cmp-1)
            {
                temp=[dateArray objectAtIndex:cnt];
                transationObj=[temp objectAtIndex:0];
            }
            NSDate *date=transationObj.tran_date;
            NSDateFormatter *dateformatter=[[NSDateFormatter alloc]init];
            [dateformatter setDateStyle:NSDateFormatterFullStyle];
            NSString *strDate=[dateformatter stringFromDate:date];
            cell.lblcatname.text=strDate;
            cnt=cnt+1;

        }

        else 
        {
            transationObj=[[Transaction alloc]init];
            NSMutableArray *temp2=[[NSMutableArray alloc]init];
            int cmp2=[dateArray count];
            if(cnt2<cmp2-1)
            {
                temp2=[dateArray objectAtIndex:cnt2];
                for(int i=0;i<[temp2 count];i++)
                {
                    transationObj=[temp2 objectAtIndex:i];
                    cell.lblcatname.text=transationObj.tran_des;

                }



            }
            cnt2=cnt2+1;


        }

        cell.backgroundColor=[UIColor grayColor];
               return cell;

    }




}

I want to create a screen as shown. Each white section does not have the same size. lengh is dynamic as it is for the user. Also is there a better approach and then adding a uitableview inside a uitableview cell?

+5
1

,

NSString *CellIdentifier=[NSString stringWithFormat="CellIdentifier%d",indexPath.row];

static NSString *CellIdentifier=@"CellIdentifier"; , uitableview , CellIdentifier.so uitableview , .

+2

All Articles