2011-10-22 2 views
-1

사용자가 여러 셀을 선택할 수있는 국가 목록이 포함 된 UITableView가 있습니다. 그러나 셀을 클릭하면 8 번째 셀마다 옆에 체크 표시가 나타납니다. 왜 그런 일이 벌어지고 있는지 전혀 알 수 없으며 단지 체크 표시 일뿐입니다. 8 번째 셀에 부착 된 코드는 실행되지 않으므로 시각적 인 것입니다. 도와주세요! 여기에 테이블의 didSelectRow 내 코드입니다 :체크 표시를 반복하는 UITableView

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

    UITableViewCell *selectedCell = [tableView1 cellForRowAtIndexPath:indexPath]; 

    if ([selectedCell accessoryType] == UITableViewCellAccessoryNone) { 
     [selectedCell setAccessoryType:UITableViewCellAccessoryCheckmark]; 
     int selectedRow = indexPath.row; 
     NSString *intString = [NSString stringWithFormat:@"%d", selectedRow]; 
     if ([intString isEqualToString: @"0"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"AR"]; 
      } 
      else { 
      countriesselected = [countriestill stringByAppendingString:@"-AR"]; 
     } 
     } 
     if ([intString isEqualToString: @"1"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"AU"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-AU"]; 
      } 
     } 
     if ([intString isEqualToString: @"2"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"BR"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-BR"]; 
      } 
     } 
     if ([intString isEqualToString: @"3"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"CA"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-CA"]; 
      } 
     } 
     if ([intString isEqualToString: @"4"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"CZ"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-CZ"]; 
      } 
     } 
     if ([intString isEqualToString: @"5"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"FR"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-FR"]; 
      } 
     } 
     if ([intString isEqualToString: @"6"]) { 
      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"DE"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-DE"]; 
      } 
     } 
     if ([intString isEqualToString: @"7"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"GB"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-GB"]; 
      } 
     } 
     if ([intString isEqualToString: @"8"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"HK"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-HK"]; 
      } 
     } 
     if ([intString isEqualToString: @"9"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"IN"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-IN"]; 
      } 
     } 
     if ([intString isEqualToString: @"10"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"IE"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-IE"]; 
      } 
     } 
     if ([intString isEqualToString: @"11"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"IL"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-IL"]; 
      } 
     } 
     if ([intString isEqualToString: @"12"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"IT"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-IT"]; 
      } 
     } 
     if ([intString isEqualToString: @"13"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"JP"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-JP"]; 
      } 
     } 
     if ([intString isEqualToString: @"14"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"MX"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-MX"]; 
      } 
     } 
     if ([intString isEqualToString: @"15"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"NL"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-NL"]; 
      } 
     } 
     if ([intString isEqualToString: @"16"]) { 
        NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"NZ"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-NZ"]; 
      } 
     } 
     if ([intString isEqualToString: @"17"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"PL"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-PL"]; 
      } 
     } 
     if ([intString isEqualToString: @"18"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"RU"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-RU"]; 
      } 
     } 
     if ([intString isEqualToString: @"19"]) { 
      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"ZA"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-ZA"]; 
      } 
     } 
     if ([intString isEqualToString: @"20"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"KR"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-KR"]; 
      } 
     } 
     if ([intString isEqualToString: @"21"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"ES"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-ES"]; 
      } 
     } 
     if ([intString isEqualToString: @"22"]) { 
      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"SE"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-SE"]; 
      } 
     } 
     if ([intString isEqualToString: @"23"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"TW"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-TW"]; 
      } 
     } 
     if ([intString isEqualToString: @"24"]) { 

      NSString *countriestill = countriesselected; 
      if ([countriesselected length] == 0) { 
       countriesselected = [countriestill stringByAppendingString:@"US"]; 
      } 
      else { 
       countriesselected = [countriestill stringByAppendingString:@"-US"]; 
      } 
     } 

    } 
    else { 
     [selectedCell setAccessoryType:UITableViewCellAccessoryNone]; 
     int selectedRow = indexPath.row; 
     NSString *intString = [NSString stringWithFormat:@"%d", selectedRow]; 
     if ([intString isEqualToString: @"0"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-AR" 
               withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"AR-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"AR" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"1"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-AU" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"AU-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"AU" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"2"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-BR" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"BR-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"BR" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"3"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-CA" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"CA-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"CA" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"4"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-CZ" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"CZ-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"CZ" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"5"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-FR" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"FR-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"FR" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"6"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-DE" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"DE-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"DE" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"7"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-GB" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"GB-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"GB" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"8"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-HK" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"HK-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"HK" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"9"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-IN" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"IN-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"IN" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"10"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-IE" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"IE-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"IE" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"11"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-IL" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"IL-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"IL" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"12"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-IT" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"IT-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"IT" 
                      withString:@""]; 
     } 
     if ([intString isEqualToString: @"13"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-JP" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"JP-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"JP" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"14"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-MX" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"MX-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"MX" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"15"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-NL" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"NL-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"NL" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"16"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-NZ" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"NZ-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"NZ" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"17"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-PL" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"PL-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"PL" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"18"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-RU" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"RU-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"RU" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"19"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-ZA" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"ZA-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"ZA" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"20"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-KR" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"KR-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"KR" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"21"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-ES" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"ES-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"ES" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"22"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-SE" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"SE-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"SE" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"23"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-TW" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"TW-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"TW" 
                      withString:@""]; 

     } 
     if ([intString isEqualToString: @"24"]) { 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"-US" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"US-" 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:@"US" 
                      withString:@""]; 


     } 
    } 
    [tableView deselectRowAtIndexPath:indexPath animated:NO]; 


} 
+7

당신이 당신의 48 개 동일한 코드 조각을 리팩토링 하시겠습니까 그것은 매우 looong의 – beryllium

답변

2

"refactor"라는 단어에 익숙하지 않은 경우 코드에서 반복되는 것을 피하기 위해 (이 경우)를 의미합니다. "DRY 프로그래밍"에 대한 아주 좋은 자습서가 온라인에 있습니다. 예를 들어, 프로그램의 다른 내용을 변경하지 않은 상태에서 약 30 행의 코드가 500 행보다 많습니다. 더 짧아지는 것 외에도 변경을하면 24 또는 48 회가 아니라 한 번만 변경하면됩니다. 마지막으로, 자신이하는 일을 훨씬 쉽게 볼 수 있습니다.

특히 trydis에 동의합니다. 문제는이 코드가 아니라 cellForRowAtIndexPath입니다. 셀을 큐에서 꺼내거나 만든 다음 [cell setAccessoryType : UITableViewCellAccessoryNone] 그렇지 않으면 대기열에 포함되지 않은 셀은 화면에서 사라진 셀에 있던 액세서리를 갖게됩니다. 한 번에 8 개의 셀을 화면에 표시하는 것으로 8 개가 표시되므로 확인 된 셀이 맨 위에서 사라지고 하단의 "다시 나타납니다".

최종 의견으로는 실시간으로 국가 코드 문자열을 작성하는 것이 약간 못 생깁니다 (그러므로 하이픈에 관한 모든 내용). NSMutableSet에 활성 코드 목록을 유지 한 다음 하이픈을 추가하려고하면 더 좋습니다. ([[countriesSelected allObjects] componentsJoinedByString @ "-"]

NSArray * countryCodes = 
    [NSArray arrayWithObjects:@"AR",@"AU",@"BR",@"CA",@"CZ",@"FR",@"DE",@"GB",@"HK",@"IN",@"IE",@"IL",@"IT", 
    @"JP",@"MX",@"NL",@"NZ",@"PL",@"RU",@"ZA",:@"KR",@"ES",@"SE",@"TW",@"US",nil]; 

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

    UITableViewCell *selectedCell = [tableView1 cellForRowAtIndexPath:indexPath]; 


    NSString *countryCode = [countryCodes objectAtIndex:indexPath.row]; 

    if ([selectedCell accessoryType] == UITableViewCellAccessoryNone) { 
     [selectedCell setAccessoryType:UITableViewCellAccessoryCheckmark]; 
     if ([countriesselected length] == 0) { 
      countriesselected = countryCode; 
     } else { 
      countriesselected = [NSString stringWithFormat:@"%@-%@",countriesselected,countryCode]]; // note change to include hyphen 

     } 

    } else { 
     [selectedCell setAccessoryType:UITableViewCellAccessoryNone]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"-%@",countryCode] 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@-",countryCode] 
                      withString:@""]; 
      countriesselected = [countriesselected stringByReplacingOccurrencesOfString:countryCode" 
                      withString:@""]; 

    } 
    [tableView deselectRowAtIndexPath:indexPath animated:NO]; 

코드를 cellForRowAtIndePath위한 :

NSString *countryCode = [countryCodes objectAtIndex:indexPath.row]; 
if ([countriesselected rangeOfString: countryCode].location != NSNotFound) { 
    [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 
} else { 
    [cell setAccessoryType:UITableViewCellAccessoryNone]; 
} 
+0

여러분의 도움을 많이 주셔서 감사합니다! 아마추어입니다. 아이폰 프로그래머, 그래서 내가 프로그램으로 배우는 일종의입니다. 내 cellForRowAtIndexPath 날 도울 수 있습니까? 내가 구현하면 [셀 setA ccessoryType : UITableViewCellAccessoryNone], 아무것도 확인되지 않습니다. 도와 주셔서 감사합니다! – Prajoth

+0

음, 각 셀을 적절한 accessoryType으로 설정해야합니다. countryCodes 배열을 전역 (또는 속성) 위에두면 cellForRowAtIndexPath에 위 코드의 맨 아래에 추가 한 코드 세그먼트가 포함될 수 있습니다. – mackworth

+1

데이터 "모델"은 각 셀 어떤 것들은 체크 표시가 있습니다. 데이터 모델이 문자열 인 경우 문자열을 조사하여 각 국가를 찾습니다. – mackworth

1

코드가 리팩토링에 대한 절실히 필요하다,하지만 난 거 사지에 나가서 문제가 세포 재사용으로 인해 발생 추측입니다. cellForRowAtIndexPath 메소드에서 dequeueReusableCellWithIdentifier를 사용하고 있습니까? 그렇다면 셀을 만들 때가 아니라 호출 할 때마다 올바른 accessoryType을 설정해야합니다.

+0

감사를 어디 것?.! 올바른 accessoryType을 설정 했습니까? 셀을 하나만 검사 할 수 없기 때문에 모든 셀이 선택되거나 전혀 선택되지 않았습니다. – Prajoth

관련 문제