iphone - UIButtonTypeRoundedRect 作为 accessoryView

标签 iphone objective-c uitableview accessoryview

我有一个 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/

相关文章:

ios - 使用 NSRegularExpression 检测字符串是否包含西里尔字母的示例

iphone - 表头中的按钮用于加载不同的 TableView

iphone - 本地保存的数据文件在模拟器中持久存在,但在真正的 iPad 设备中不存在......我迷路了

iphone - 在 iPhone 上制作条形图

ios - 定义 FastImageCache FICImageFormats 的最佳实践?

ios - 在 TableView 中选择行时看到相应的 View Controller

iphone - 当方向发生时如何刷新 UIView?

mysql - 如何正确缓存/更新使用远程数据库的数据驱动 iPhone 应用程序?

iphone - iOS 开发 : How can I cause a UITableViewCell to change into an editable UITextField when it's tapped?

ios - UITableView 部分页脚在插入新表格行后移动