在UITableview中选择多行 [英] Select multiple rows in UITableview

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

问题描述

我想在UITableview中选择多行,就像Apple在原生闹钟应用中所做的那样(参见图片

I would like to select multiple rows in a UITableview just like Apple does in the native Alarm app (see picture

我该怎么做?

到目前为止我看到的所有答案都是旧的(和说不能做)或引用本机邮件应用程序中的多行选择。这种方法不是我想要的,因为你必须首先输入编辑模式。我希望能够选择马上行。

All the answers I saw so far were old (and said "Can't do") or refer to the multiple row selection in the native Mail app. That method is not what I would like because you have to enter in the "edit"-mode first. I want to be able to select the rows right away.

希望有人可以提供帮助。

Hope someone can help.

Christian

Christian

推荐答案

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

do

    if([tableView cellForRowAtIndexPath:indexPath].accessoryType == UITableViewCellAccessoryCheckmark){
       [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone;
    }else{
       [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
    }

编辑:

您还必须使用映射已检查单元格的数组,并且在cellForRowAtIndexPath中您必须验证是否应检查accessoryType。

You also have to use an array that maps the checked cells and in cellForRowAtIndexPath you have to verify if the accessoryType should be checked or not.

这篇关于在UITableview中选择多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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