我有一个 TableView ,我想在每个单元格的右侧放置一个标签,所以在 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
我有一些这样的代码
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.titleLabel.text = @"title";
cell.accessoryView = button;
但是,该按钮根本不显示。有人知道为什么吗? 我确定声明是正确的,因为如果我用
替换按钮声明UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
然后按钮出现了,这让我觉得圆角矩形也应该出现。
最佳答案
尝试检查按钮的 frame
是否等于 CGRectZero
,如果是,则将其设置为适当的值。
关于iphone - UIButtonTypeRoundedRect 作为 accessoryView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2928236/