I’m trying to add as subview into a section in UITableView, It looks like the code is correct, the it doesn’t show anything, just blank section. Here’s the code that I use:
- (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;
}
Thanx in advance..
One of the problems is that you are trying to change the height of the cell. If you want to do so, in addition to changing its frame, you must also implement
tableView:heightForRowAtIndexPath:and return appropriate values for each row. If page is properly loaded (assuming it’s a view controller), you can add the view as a subview. Make sure its frame falls within the bounds of the cell.Attaching the view
Since
dPageis a view controller, you will have to declarepageas anivarof classdPageand then do this inviewDidAppear:,and
tableView:cellForRowAtIndexPath:remains unchanged.