I’d like to display UIButton only in UITableView at even indexPath.row.
But, UIButton appears in all cells.
if (indexPath.row % 2 == 0) {
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(160, 140, 80, 40);
[button setTitle:@"button" forState:UIControlStateNormal];
[cell addSubview:button];
}
How can I resolve this problem?
Thanks.
First make sure what is the height of the cell :
You may be facing the issue because of height of button.
It should be more or equal to the Button’s height.
Additionally replace your code with this.