在tableView中选择Multiple cell并在另一个tableView Cell中显示所选单元格作为标签? [英] Select Multiple cell in tableView and display the selected cell in another tableView Cell as a label?

查看:15
本文介绍了在tableView中选择Multiple cell并在另一个tableView Cell中显示所选单元格作为标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在创建一个与 iOS 默认闹钟相关的应用.我在 tableView 中选择多个单元格.如果我单击后退按钮,所选单元格将在 tableViewCell 中显示为另一个视图中的标签.我正在使用故事板.如何做到这一点?

Hi I'm creating an app related to iOS default alarm. I'm selecting a multiple cell in tableView. If I click the back button the selected cells are displayed in tableViewCell as a label in another view. I'm Using story board. How to do this?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *thisCell = [tableView cellForRowAtIndexPath:indexPath];
    if (thisCell.accessoryType == UITableViewCellAccessoryNone) {
       thisCell.accessoryType = UITableViewCellAccessoryCheckmark;
       [myIndexArray addObject:[NSString stringWithFormat:@"%d",indexPath.row]];
}
else
{
    thisCell.accessoryType = UITableViewCellAccessoryNone;
    for(int i=0; i<myIndexArray.count; i++)
    {
        if([[myIndexArray objectAtIndex:i]intValue]== indexPath.row)
        {
            [myIndexArray removeObjectAtIndex:i];
            break;
        }
    }
 }
 }

我想要这样的示例图片

我想要重复视图之类的东西,然后按后退按钮,所选单元格将显示在重复 tableViewCell 中.

I want something like a Repeat View and press back button the selected cells are displayed in Repeat tableViewCell.

推荐答案

我在我的应用程序中做了同样的事情.我可以帮你...
RepeatDayViewController

I did the same in my app. I can help you...
RepeatDayViewController

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

  if (UITableViewCellAccessoryNone == cell.accessoryType ) 
   {

    cell.accessoryType = UITableViewCellAccessoryCheckmark;
    NSNumber *dayNumber = [NSNumber numberWithInteger:indexPath.row];
    [self.repeatDays addObject:dayNumber];
   }
  else
  {
    cell.accessoryType = UITableViewCellAccessoryNone;
    NSNumber *dayNumber = [NSNumber numberWithInteger:indexPath.row];
    [self.repeatDays removeObject:dayNumber];

   }
}

我将 self.repeatDays 传递给 AddAlarmViewController


AddAlarmViewController
我有一个这样的数组

In
AddAlarmViewController
I have an array like this

 _days = [[NSArray alloc ]initWithObjects:@"Sun",@"Mon",@"Tue",@"Wed",@"Thu",@"Fri",@"Sat",nil];


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

         if ([self.repeatDays count]) 
            {
                NSMutableArray *repeatDays = [NSMutableArray array]; 

                for (NSNumber *dayNumber in self.repeatDays) 
                {

                    [repeatDays addObject:[_days objectAtIndex:[dayNumber integerValue]]];
                }
                NSString *repeatLabel = [repeatDays componentsJoinedByString:@" "];
                cell.detailTextLabel.text = repeatLabel;

            }
            else
            {
                cell.detailTextLabel.text = NSLocalizedString(@"Never",nil);
            }

}

这篇关于在tableView中选择Multiple cell并在另一个tableView Cell中显示所选单元格作为标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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