Ios 将子视图添加到UITable

Ios 将子视图添加到UITable,ios,uitableview,uiview,xcode4,Ios,Uitableview,Uiview,Xcode4,我正在尝试将as子视图添加到UITableView的一个部分中,看起来代码是正确的,它没有显示任何内容,只是空白部分。以下是我使用的代码: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell

我正在尝试将as子视图添加到UITableView的一个部分中,看起来代码是正确的,它没有显示任何内容,只是空白部分。以下是我使用的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ 
    static NSString *CellIdentifier = @"Cell";

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

    if(indexPath.section==0){
        cell.textLabel.text =@"<>";
    }else if(indexPath.section==1){
        if(indexPath.row==1){
            cell.frame =CGRectMake(0,0, 100, 100);
            [cell.contentView addSubview:page.view];
        } 
    } else if(indexPath.section==2){

    }


    // Configure the cell.
    return cell;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{ 
静态NSString*CellIdentifier=@“Cell”;
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
如果(单元格==nil){
cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:CellIdentifier]自动释放];
}
if(indexPath.section==0){
cell.textlab.text=@”;
}else if(indexPath.section==1){
if(indexPath.row==1){
cell.frame=CGRectMake(0,01000);
[cell.contentView addSubview:page.view];
} 
}else if(indexPath.section==2){
}
//配置单元格。
返回单元;
}

提前支付

问题之一是您试图更改单元格的高度。如果要执行此操作,除了更改其帧外,还必须实现
tableView:heightforrowatinexpath:
,并为每行返回适当的值。如果页面已正确加载(假设它是视图控制器),则可以将视图添加为子视图。确保其框架位于单元格的边界内

附加视图

由于
dPage
是一个视图控制器,因此必须将
page
声明为
dPage
类的
ivar
,然后在
viewdide:
中执行此操作

page = [[dPage alloc] initWithNibName:"page" bundle:nil];

tableView:cellForRowAtIndexPath:
保持不变。

什么是
页面
page.view.frame
的值是多少?它是一个类,一个包含page.xib的类。。我正在尝试将xib视图添加到表部分..我认为这不是问题,因为我以自己的方式进行了尝试,会话仍然是空白。。我怀疑在调用节时.xib为null。。有没有办法证实这一点?我确实说过页面是否正确加载。你是如何加载它的,你能更新代码吗?你是指page.xib还是mainpage.xib?你在哪里加载
page.xib
?我想我不会加载它,因为我认为调用节时会自动调用page.xib(这是上面的代码)。对不起,如果我错了,因为我刚开始学习xcode不到一个月。