2011-08-22 3 views
1
static NSString *cellIdentifier = @"Cell"; 
AssignmentTableCell *cell = (AssignmentTableCell *) [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
if(cell == nil) { 
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"AssignmentTableCell" owner:self options:Nil]; 
    cell = [nib objectAtIndex:0]; 
} 

다음은 맞춤형 셀 초기화를위한 코드입니다. 난 사용자 정의 셀에 대한 uitouch를 감지하고 UItableView의 DidSelected 이벤트를 사용하는 대신보기 컨트롤러를 밀고 있습니다. 하지만 내가 직면하고있는 문제는Custom UiTableViewCell의 멀티 터치 문제

입니다. 한 번에 2 줄을 선택할 수 있습니다. 이는 내 의도가 아니며 응용 프로그램이 손상 될 수 있습니다. 멀티 터치를 사용하지 않으려했지만 사용하지 않았습니다. 그들은 여전히 ​​한 번에 2 개의 세포를 계속 선택합니다.

도움이 될 것입니다.

편집 1 : 여기

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    imgBg.image = [UIImage imageNamed:@"rowSelected.png"]; 
    [[self delegate] touchStarted:tag]; 
} 

-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    imgBg.image = [UIImage imageNamed:@"7CustomCellBackground.png"]; 
    [[self delegate] touchEnded:tag]; 
} 

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    //imgBg.image = [UIImage imageNamed:@"7CustomCellBackground.png"]; 
    [[self delegate] rowTocuchedFromClicked:tag]; 
} 

셀의 접촉 방법이다.

답변

1

셀에서 터치를 감지하는 방법과 관련된 코드를 추가 할 수 있습니까? 또한 선택한 셀을 선택 취소하지 않았기 때문에 여러 선택 항목이 표시되는 이유입니다. 충돌에 대한 이유는 콘솔 로그를 붙여 후에 만 ​​확인 될 수있는 다른 뭔가입니다 같은 -

-(void) tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath)indexPath 
{ 
    [tableView deselectRowAtIndexPath: indexPath animated: YES]; 
    //your other stuff 
} 

뭔가.

HTH,

하기 Akshay

+0

코드는 당신이이 같은 셀에 터치를 감지 할 필요가 있다고 생각하지 않습니다 그것을 – chsab420

+0

을 확인하시기 바랍니다 덧붙였다. 커스텀 셀에 서브 뷰가 여러 개있는 경우,'addTarget : action : forControlEvents'를 사용하여 대상을 추가해야합니다. 크래시 로그를 붙여 넣지 않았습니다. 제안 후에 다중 선택이 작동합니까? – Akshay

+0

실제로 충돌 로그는 아무 것도 아니지만 동시에 두 행을 터치하면 네비게이션 컨트롤러가 한 번에 두 개를 푸시 할 수 없다는 오류를 표시합니다. – chsab420