Custom Cell over lapping
I am trying to use a custom cell, My custom cell is of size 320*220 pixels. My table size is 320* by 1500 which is large enough I have set custom cell's view in scale to fill mode. But when i fill the table using custom cell all i see is first row. i have total four rows to be filld in a custom way. but they gets overlapped and i can not see any of the table.. They do look, but overlapped, Any hints .. about why its happening Do i need to make changes into nib?
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndex开发者_如何转开发Path *)indexPath{ static NSString *CellIdentifier = @"CustomCell";
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
for (id oneObject in nib)
if ([oneObject isKindOfClass:[CustomCell class]])
cell = (CustomCell *)oneObject;
}
cell.iconImage.image = [UIImage imageNamed:[NSString stringWithFormat:@"beach%d.jpg",indexPath.row+1]];
cell.title.text=[[RArrray objectAtIndex:indexPath.row] objectForKey:@"Beach"];
return cell;
}
The cells are resized to the row height. Try setting tableView.rowHeight = 220
.
EDIT: Avoid implementing tableView:heightForRowAtIndexPath:
; if you do, it's called for every row, which becomes a problem when your table gets large (see the docs for more)
Not really sure I follow you, but if it's any help overlapping usually happens because you didn't set the rowHeight for a tableview. Try this -
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 220; // Or whatever your cell height is?
}
精彩评论