xcode 我们如何在 uitableviewcell 中放置一个复选框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5138855/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can we put a checkbox in uitableviewcell
提问by Steve Gear
I created list of todos. Now I want to put the checkbox for each one cell. When I mark it as checked, it can be marked and then we select delete button if we want, which is also in the same cell at right side and deleted, but I am not able to perform action like this.
我创建了待办事项列表。现在我想为每个单元格放置复选框。当我将其标记为已选中时,可以对其进行标记,然后我们根据需要选择删除按钮,该按钮也在右侧的同一单元格中并被删除,但我无法执行这样的操作。
Can anyone please help me?
谁能帮帮我吗?
回答by Sudhanshu
@Chakradhar not a big issue you can do it very easily with or without using custom images .. in your didSelectRowAtIndexPath
delegate try to check and give the UITableViewCellAccessory
as per your condition ....this is the way in which there is no need to use extra images and you can checked for you particular selected cell..
@Chakradhar不是一个大问题,你可以使用或不使用自定义图像..在你做到这一点很容易didSelectRowAtIndexPath
委托尝试检查,并给予UITableViewCellAccessory
按你的条件....这是在没有必要使用额外的方式图像,您可以检查特定选定的单元格..
if (//here you check)
{ // item needed - display checkmark
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else
{ // not needed no checkmark
cell.accessoryType = UITableViewCellAccessoryNone;
}
Take this shopping tutorialand see didSelectRowAtIndexPath
delegate method see how they had used the condition.
看看这个购物教程,看看didSelectRowAtIndexPath
委托方法,看看他们是如何使用条件的。
Edited as per you last comment:For custom accessory view look for Implement a Custom Accessory View For UITableView in iPhone
根据您上次评论进行编辑:对于自定义附件视图,请查找在 iPhone 中为 UITableView实现自定义附件视图
Good Luck!
祝你好运!
回答by visakh7
Use this
用这个
cell.accessoryType = UITableViewCellAccessoryCheckmark;
回答by Swastik
You can actually add custom buttom with unchecked image on your cell.On button action method you can change the image to checked & handle rest of things you want to handle
您实际上可以在您的单元格上添加带有未选中图像的自定义按钮。在按钮操作方法中,您可以将图像更改为选中并处理您想要处理的其余内容