2010-07-08 3 views
1

테이블 뷰가 있으며 섹션 A의 행을 스 와이프하고 나면 섹션 B의 행을 선택할 때마다 섹션 A에서 스 와이프 된 행을 선택했다고 생각합니다! 나는 브레이크 포인트를 배치하여 그것이 셀이라고 생각하는지 100 % 확신하고 섹션 B의 행을 선택할 때 그것을 호출합니다.테이블 뷰에서 행을 스 와이프하고 다른 것을 클릭하면 스 와이프가 선택됩니다.

슬쩍 내 말은 손가락 하나를 일부 셀 , 좌우로 드래그 (중요하지 않음) 한 다음 놓습니다. didSelectRowAtIndexPath는 탭이 아니기 때문에 호출하지 않습니다.

예 :

내가 뭔가 잘못하고 있습니까 A.1 : didSelectRowAtIndexPath :있는 tableView indexpath의 A.1에
출근 indexpath의 B.4
OS에
을 눌러 호출? 무엇이 잘못 될 수 있습니까? 특정 세포에 접촉을 처리

전체 코드 : 슬쩍 감지하고 처리 할 때

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 
    RDLogString(@"(%p) Received touches began", self); 
    moveCount = 0; 
    UITouch * touch = [touches anyObject]; 
    touchBegin = [touch locationInView: nil]; 
    [[self nextResponder] touchesBegan: touches withEvent: event]; 
} 

- (void) touchesMoved: (NSSet * const)touches withEvent:(UIEvent * const)event { 
    RDLogString(@"(%p) Received touches moved", self); 
    moveCount++; 
    [[self nextResponder] touchesMoved: touches withEvent: event]; 
} 

- (void) touchesEnded: (NSSet * const)touches withEvent:(UIEvent * const)event { 
    RDLogString(@"(%p) Received touches ended", self); 
    if(![self checkUserSwipedWithTouches: touches]){ 
     [[self nextResponder] touchesEnded: touches withEvent: event]; 
    } 
} 

- (BOOL) checkUserSwipedWithTouches: (NSSet * const) touches { 
    CGPoint touchEnd = [[touches anyObject] locationInView: nil]; 
    NSInteger distance = touchBegin.x - touchEnd.x; 

    // This code shows an animation if the user swiped 
    if(distance > SWIPED_HORIZONTAL_THRESHOLD){ 
     [self userSwipedRightToLeft: YES]; 
     return YES; 
    } else if (distance < (-SWIPED_HORIZONTAL_THRESHOLD)) { 
     [self userSwipedRightToLeft: NO]; 
     return YES; 
    } 

    return NO; 
} 
+0

귀하의 문제가 여전히 불분명 틱입니다. 소스 코드 예제를 제공해 주시겠습니까? 또한 "스 와이프"란 무엇을 의미합니까? 선택하거나 제거한다는 의미입니까? –

답변

1

내가 대신 아무것도 보내지 않고, 나는 지금 많이 만드는 touchesCancelled를 보내,하여 고정 돌이켜 보면 나는 인정해야하지만, 내가 그렇게해야한다는 것은 분명하지 않다. 작업을 처리하지 않으려는 경우 수행 할 작업에 대한 적절한 문서를 찾을 수 없습니다. 작동

코드 :

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 
    moveCount = 0; 
    UITouch * touch = [touches anyObject]; 
    touchBegin = [touch locationInView: nil]; 
    [[self nextResponder] touchesBegan: touches withEvent: event]; 
} 

- (void) touchesMoved: (NSSet * const)touches withEvent:(UIEvent * const)event { 
    moveCount++; 
    [[self nextResponder] touchesMoved: touches withEvent: event]; 
} 

- (void) touchesEnded: (NSSet * const)touches withEvent:(UIEvent * const)event { 
    // If we DO NOT handle the touch, send touchesEnded 
    if(![self checkUserSwipedWithTouches: touches]){ 
     [[self nextResponder] touchesEnded: touches withEvent: event]; 
    } else { // If we DO handle the touch, send a touches cancelled. 
     self.selected = NO; 
     self.highlighted = NO; 
     [[self nextResponder] touchesCancelled: touches withEvent: event]; 
    } 
} 
관련 문제