在uitableviewcells问题中添加uitableview?

ios*_*111 5 iphone objective-c uitableview

在此输入图像描述我有一个iphone应用程序,其中我在uitableviewcell.in中添加uitableview,每个uitablecell包含tableview,其中有基于用户entry.ie的第一个单元格中的tableview包含3行.tableview在秒行包含4行.它变化.我的问题是,当我滚动tableview然后重复输入条目.我可以解决这个问题吗?任何教程或示例代码?

 -(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;

    }




}
Run Code Online (Sandbox Code Playgroud)

我想创建如图所示的屏幕.其中每个白色部分的大小不同.根据用户条目,lengh是动态的.那么有没有更好的方法然后在uitableview单元格中添加uitableview?

ios*_*111 2

我已经通过使用解决了这个问题

NSString *CellIdentifier=[NSString stringWithFormat="CellIdentifier%d",indexPath.row];
Run Code Online (Sandbox Code Playgroud)

而不是 static NSString *CellIdentifier=@"CellIdentifier";在第一个表视图中,但我知道这将使 uitableview 缓慢滚动,因为它也不会重用 CellIdentifier。因此任何人都可以提供更好的解决方案或更好的方法来使 uitableview 嵌套,我将不胜感激。