2015-01-06 3 views
-1

내가 storyboards.I가모든 섹션에서 단일 행을 선택하는 방법은 무엇입니까?

내가 모든 부분에서 하나의 행을 선택하고 선택한 행의 값을 취득 할
Alpha 
a 
b > 
Numb 
1 > 
2 
3 

같은 두 개의 섹션으로 jQuery과 구현 사용하여 iOS 앱을 짓고 있어요.

나는 이것을 할 수 없다. 나를 도울 수있다. 한 번에 선택 한 행이 있음을

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    // Uncheck the previous checked row 
    long sec = [indexPath section]; 
    if(sec==0){ 
    if(self->checkedIndexPath) 
    { 
     UITableViewCell* uncheckCell = [tableView 
             cellForRowAtIndexPath:self->checkedIndexPath]; 
     uncheckCell.accessoryType = UITableViewCellAccessoryNone; 
    } 
    if([self->checkedIndexPath isEqual:indexPath]) 
    { 
     self->checkedIndexPath = nil; 
    } 
    else 
    { 
     UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath]; 
     cell.accessoryType = UITableViewCellAccessoryCheckmark; 
     self->checkedIndexPath = indexPath; 
    } 
    } 
    else if(sec==1){ 
     if(self->checkedIndexPath) 
     { 
      UITableViewCell* uncheckCell = [tableView 
              cellForRowAtIndexPath:self->checkedIndexPath]; 
      uncheckCell.accessoryType = UITableViewCellAccessoryNone; 
     } 
     if([self->checkedIndexPath isEqual:indexPath]) 
     { 
      self->checkedIndexPath = nil; 
     } 
    } 
} 
+0

UITableView 인스턴스에 대해 다중 선택 = ON으로 설정하십시오. – Anon

답변

0

선택 해제 같은 section.So에서 선택된 행 :

여기 내 코드입니다.

- (NSIndexPath*)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath*)indexPath { 
    for (NSIndexPath* selectedIndexPath in tableView.indexPathsForSelectedRows) { 
     if (selectedIndexPath.section == indexPath.section) 
      [tableView deselectRowAtIndexPath:selectedIndexPath animated:NO] ; 
    } 
    return indexPath ; 
} 
+0

안녕하십니까, 빠른 답장을 보내 주셔서 감사합니다. 내 경우에는 작동하지 않습니다. 초 단위로 한 행만 선택할 수 있습니다. – Hitesh

관련 문제