无法为UITableViewCellAccessoryCheckmark选择UITableView中的单元格 [英] Can't select Cell in UITableView For UITableViewCellAccessoryCheckmark

查看:37
本文介绍了无法为UITableViewCellAccessoryCheckmark选择UITableView中的单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您已在iOS中使用过Messages应用程序,则知道我们如何通过编辑按钮在任何消息中调用 UITableViewCellAccessoryCheckmark ,然后选择每个气泡/单元格以进行转发或删除.

If you have used Messages application in iOS, you know how we could invoke UITableViewCellAccessoryCheckmark in any message through edit button and then select each bubble/cell for forward or deletion purpose.

我正在尝试在我的应用程序中执行相同的操作.我可以点击Edit并显示 UITableViewCellAcessoryCheckMark ,但是我无法选择使用它的单元格.我还需要实施什么?

I'm trying to do the same in my application. I can tap on edit and UITableViewCellAcessoryCheckMark is shown, but I can't select the cells using it. What more do I need to implement?

任何帮助将不胜感激.这是代码-

Any help would be appreciated. Here is the code -

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.navigationItem.rightBarButtonItem  = self.editButtonItem;
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
        return UITableViewCellAccessoryCheckmark;
}

推荐答案

对于如图所示的表格视图,可以在其中选中一个或多个带有选中标记的单元格,必须设置 allowsMultipleSelectionDuringEditing = YES在表格视图上.可以在 viewDidLoad 中使用

For a table view as shown in the picture, where one or more cells can be selected with a checkmark symbol, you have to set allowsMultipleSelectionDuringEditing = YES on the table view. This can be done either in viewDidLoad with

self.tableView.allowsMultipleSelectionDuringEditing = YES

或在NIB/Storyboard文件中的表格视图的属性"检查器中,通过将编辑"设置为编辑期间的多重选择".

or in the Attributes Inspector of the table view in the NIB/Storyboard file by setting "Editing" to "Multiple Selection During Editing".

不需要 tableView:editingStyleForRowAtIndexPath:方法.

(然后您的方法返回 UITableViewCellAccessoryCheckmark ,它是 UITableViewCellAccessoryType 而不是 UITableViewCellEditingStyle .)

(And btw your method returns UITableViewCellAccessoryCheckmark which is a UITableViewCellAccessoryType and not a UITableViewCellEditingStyle.)

这篇关于无法为UITableViewCellAccessoryCheckmark选择UITableView中的单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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