UITableView 子视图到 uitableviewcell
我正在尝试向表格视图添加一个按钮,无论我指定哪个框架,该按钮都是不可见的。这是一个自定义 UITableViewCell,我在代码中而不是在 xib 文件中添加按钮,以便我可以单击按钮并执行不是 didSelectRowAtIndexPath 的操作: 我在 cellForRowAtIndexPath 中有以下代码:我缺少什么?
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
button.frame = bframe;
button.userInteractionEnabled = YES;
[button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:button];
return cell;
i am trying to add a button to the tableview and no matter what frame i specify the button is not visible. This is a custom UITableViewCell and I am adding the button in the code rather than in the xib file is so that I can click on the button and perform an action which is not didSelectRowAtIndexPath:
I have the following code in cellForRowAtIndexPath: What am I missing?
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
button.frame = bframe;
button.userInteractionEnabled = YES;
[button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:button];
return cell;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个
UIButton *button = [[UIButton buttonWithType:UIButtonTypeDetailDisclosure] keep];
try this
UIButton *button = [[UIButton buttonWithType:UIButtonTypeDetailDisclosure] retain];