I want to display a customized button with “!” as its text inside a UITableView cell. The code is like this:
UIButton *informationBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[informationBtn setFrame:CGRectMake(10, 5, 55, 55)];
[informationBtn setTitle:@"!" forState:UIControlStateNormal];
[informationBtn addTarget:self action:@selector(popUpWindowWithMessage:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:informationBtn];
where “cell” is defined as a UITableViewCell instance.
But the button doesn’t appear on the cell. What should I do to display the button?
Your code is correct, And it seems the button is there. But you can’t see it. Change the color of button title. other than white. then check..
Add the above line after setting title of your button.