Reputation: 174
Starting my quest into ios development but I have a problem, below.
The plan:
The result:
Upvotes: 1
Views: 1297
Reputation: 691
You need to set height of your custom cell using tableview delegate method
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0) {
return 150.0;
}else if (indexPath.row == 1){
return 300.0;
}
return 0.0;
}
as well as u need to set your custom cell cliptobound property to yes in datasource method
- (CGFloat)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
customcell *cell = (customcell *)[tableView dequeResusableCellWithIdentifier:@"newcell" forIndexPath:indexPath];
cell.cliptobound = YES;
return cell;
}
Upvotes: 5
Reputation: 3541
Your cells are getting reused without the content being reset in cellForRowAtIndexPath. In that method you need to blank out the cell content before putting more content in it.
Upvotes: 0
Reputation: 4513
Your tableview needs to know the height of your custom cell, use the following tableview delegate method:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0) {
return 100.0;
}
return 200.0;
}
Upvotes: 1