如何在编辑模式下选择行? [英] How to select rows while in edit mode?

查看:107
本文介绍了如何在编辑模式下选择行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可编辑的UITableView。我提交更改通过:

I have a UITableView that is editable. I am commiting changes via:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

在编辑模式下,我希望用户能够选择一行,这将推出一个新的观点。我不知道如何做到这一点。我怀疑它将在:

While in edit mode, I would like the user to be able to select a row, which will push a new view. I am not sure how to do this. I suspect it will be in:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

但是如何确定用户是否处于编辑模式?

But how can I determine if the user is in edit mode or not?

更新:
编辑模式通过以下方式切换:

UPDATE: Edit Mode is toggled via:

self.navigationItem.rightBarButtonItem = self.editButtonItem;


推荐答案

要允许在编辑过程中进行选择, code> allowSelectionDuringEditing 属性 UITableView 为YES。然后它将调用 didSelectRowAtIndexPath 消息。您可以在这里找到有关该资源的详情:

To allow selection during editing you need to set the allowsSelectionDuringEditing property of UITableView to YES. Then it will call the didSelectRowAtIndexPath message. You can find more information about that property here:

http://developer.apple.com/iphone/library/documentation/uikit/reference/UITableView_Class/Reference /Reference.html#//apple_ref/occ/instp/UITableView/allowsSelectionDuringEditing

然后,您可以通过运行代码查看用户是否处于编辑模式如下:

Then, you can see if the user is in edit mode by running code like the following:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (tableView.editing == YES) {
        // Table view is editing - run code here
    }
}

这篇关于如何在编辑模式下选择行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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