0

こんにちは、iOS のデフォルト アラームに関連するアプリを作成しています。tableView で複数のセルを選択しています。戻るボタンをクリックすると、選択したセルが別のビューのラベルとして tableViewCell に表示されます。ストーリーボードを使用しています。これを行う方法?

- (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;
        }
    }
 }
 }

こんな風に欲しいサンプル画像

リピートビューのようなものが欲しいので、戻るボタンを押して、選択したセルをリピートテーブルビューセルに表示します。

4

2 に答える 2

1

私は自分のアプリで同じことをしました。お手伝いしましょう...
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
ような配列を持っています

 _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);
            }

}
于 2013-02-20T08:56:07.753 に答える
0

ユーザーが行を選択するたびに、アクションを保存します。NSUserDefaults

の中に

-(void)viewDidAppear:(BOOL)animated{


 UITableViewCell*   testCell = [azanTableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];

if ([[NSUserDefaults standardUserDefaults]boolForKey:@"testCell"]==YES) {
    testCell.accessoryType = UITableViewCellAccessoryCheckmark;
    testCell .textLabel.textColor = [UIColor colorWithRed:0.22 green:0.33 blue:0.53 alpha:1.0];
}

}

等々...

于 2013-02-20T08:41:51.457 に答える