UIButtonTypeRoundedRect 作为附件视图
我有一个表格视图,我想在每个单元格的右侧放置一个标签,因此在 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
中我有一些像这样的代码
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.titleLabel.text = @"title";
cell.accessoryView = button;
但是,该按钮根本不显示。有人知道为什么吗? 我确信声明是正确的,因为如果我用 替换按钮声明,
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
那么按钮就会出现,这让我认为圆角矩形也应该出现。
I have a table view and I want to put a label on the right of each cell, so in - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
I'm having some code like this
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.titleLabel.text = @"title";
cell.accessoryView = button;
However, the button is not displaying at all. Anyone know why?
I am sure that the declaration is correct, because if I replace the button declaration with
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
then the button appears, which make me think that the rounded rectangle should also appear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试检查按钮的
frame
是否等于CGRectZero
,如果是,请将其设置为适当的值。Try checking if the button's
frame
is equal toCGRectZero
and if so, set it to an appropriate value.