以编程方式将按钮添加到表格视图单元格 [英] Add buttons programmatically to table view cells

查看:71
本文介绍了以编程方式将按钮添加到表格视图单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在表格视图中添加和删除单元格.如何为每个添加的单元格有两个按钮?

I can add and delete cells to my table view. How to have two buttons for each cell that's added?

推荐答案

将按钮添加为单元格的子视图.而已.我给了样品:

Add the button as subview for your cell. That's it. I have given the sample:

//Create your cell then do the following    
UIButton *newBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[newBtn setFrame:CGRectMake(10,5,55,55)];
[newBtn addTarget:self action:@selector(yourSelector:) forControlEvents:UIControlEventTouchUpInside];

[cell addSubview:newBtn];

这篇关于以编程方式将按钮添加到表格视图单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆