Iphone 加上「;加上;AccessoryType表视图的按钮

Iphone 加上「;加上;AccessoryType表视图的按钮,iphone,uitableview,accessorytype,Iphone,Uitableview,Accessorytype,我正在尝试实现一个TableView,其中每个单元格都有一个“+”按钮,就像在向播放列表中添加歌曲时的iPod应用程序一样 单元格.accesoryType只有四个值 UITableViewCellAccessoryCheckmark UITableViewCellAccessoryDetailDisclosureButton UITableViewCellAccessoryDisclosureIndicator 及 如何做到这一点?我需要创建一个自定义按钮并设置单元格。accessoryV

我正在尝试实现一个TableView,其中每个单元格都有一个“
+
”按钮,就像在向播放列表中添加歌曲时的iPod应用程序一样

单元格.accesoryType
只有四个值

UITableViewCellAccessoryCheckmark

UITableViewCellAccessoryDetailDisclosureButton
UITableViewCellAccessoryDisclosureIndicator


如何做到这一点?我需要创建一个自定义按钮并设置
单元格。accessoryView
还是有其他方法可以做到这一点?

如果要创建
自定义单元格
,则在其右角放置一个
按钮
,就像
附件类型
出现的位置一样,并将“+”图像指定给该按钮,以便“查看图像”并获取“按钮操作事件”

有关自定义uitableviewcells,请参阅教程。

您可以查看

另请检查

Teo的解决方案效果很好,但它并没有作为答案发布,所以我重新发布它:

UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd];
[button addTarget:self action:@selector(addbuttonTapped) forControlEvents:UIControlEventTouchUpInside];
cell.accessoryView = button;

约瑟夫的一个简单变体,用于记忆

如果您只需要一个装饰性的“+”按钮并继续使用原始的didSelectRowAtIndexPath触发器,请使用:

UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd];
[button setUserInteractionEnabled:NO];
cell.accessoryView = button;

通过禁用按钮上的用户交互,它将在底层视图(单元格)上传播压力事件。

哦,是的,这可能是真的。我不明白他可能想编辑表格并向表格中添加行,苹果会给绿色“+”符号?!找到解决方案UIButton*按钮=[UIButton buttonWithType:UIButtonTypeContactAdd];[button addTarget:self action:@selector(buttonTapped:event:)forControlEvents:UIControlEventTouchUpInside];cell.accessoryView=button;并创建了事件处理过程-(void)buttonTapped:(id)发送者事件:(id)事件{}
UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd];
[button setUserInteractionEnabled:NO];
cell.accessoryView = button;