Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 标识标记的单元格行_Ios_Objective C_Iphone - Fatal编程技术网

Ios 标识标记的单元格行

Ios 标识标记的单元格行,ios,objective-c,iphone,Ios,Objective C,Iphone,我正在尝试实现selectalarmday页面,就像iPhone中的报警屏幕一样。我可以一次标记多个单元格,但问题是,当我标记第1行和第2行时,我无法识别这两行是否已标记。有人能帮我吗 这是我已经实现的屏幕] NSUserDefaults *dd=[NSUserDefaults standardUserDefaults]; UITableViewCell *cell= [tableView cellForRowAtIndexPath:path]; if (path.row==0) {

我正在尝试实现selectalarmday页面,就像iPhone中的报警屏幕一样。我可以一次标记多个单元格,但问题是,当我标记第1行和第2行时,我无法识别这两行是否已标记。有人能帮我吗

这是我已经实现的屏幕]

NSUserDefaults *dd=[NSUserDefaults standardUserDefaults];


  UITableViewCell *cell= [tableView cellForRowAtIndexPath:path];

if (path.row==0) {
    if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
        cell.accessoryType = UITableViewCellAccessoryNone;



    } else {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;


        [dd setObject:@"sun" forKey:@"key"];

        day=@"sun";


    }

}
if (path.row==1) {
    if (Tablcell.accessoryType == UITableViewCellAccessoryCheckmark) {
        Tablcell.accessoryType = UITableViewCellAccessoryNone;
    } else {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;

        day=@"mon";
            [dd setObject:@"mon" forKey:@"key"];

    }

[dd synchronize];
}

步骤:1

创建一个相互数组

NSMutableArray *selectedIndexArray;
步骤:2 在didSelectItemAtIndexPath方法中,在selectedIndexArray中添加索引值

NSString *str = [NSString stringWithFormat:@"%ld",(long)indexPath.item];
[selectedIndexArray addObject:str];
NSString *str = [NSString stringWithFormat:@"%ld",(long)indexPath.item];
if([selectedIndexArray containsObject:str]){

        [selectedIndexArray removeObject:str];
}
步骤:3 在didDeselectItemAtIndexPath方法中,从selectedIndexArray中删除索引值

NSString *str = [NSString stringWithFormat:@"%ld",(long)indexPath.item];
[selectedIndexArray addObject:str];
NSString *str = [NSString stringWithFormat:@"%ld",(long)indexPath.item];
if([selectedIndexArray containsObject:str]){

        [selectedIndexArray removeObject:str];
}
步骤:4


现在,当您要检查标记了哪些行时,可以使用此数组在单元格中显示/隐藏选中的按钮。

当我按下后退按钮时,我要获取标记的行值。看起来后退按钮是导航项。你可以检查它何时被按下,但它是一个不同的故事。你可以做一件事。看起来您的多重选择已启用。您可以在方法VIEWWILLOVERE中检查IndExpathForSelectedRows。或者添加自定义后退按钮,向其添加方法,然后在按下该按钮时选中**indexPathsForSelectedRows**。如何在方法视图中检查indexPathsForSelectedRows将消失。我不使用这些方法