1
我有一個tableview,並且每當我在A部分中滑動一行,然後在部分B中選擇一行時,它認爲我選擇了部分A中的滑動行!我放置了一個斷點來驗證,並且100%確定它認爲它是該單元格,並且在我選擇B部分中的行時將其稱爲它。在tableview中滑動一行,點擊其他,選擇滑動
通過滑動我的意思是您將手指放在單元格的某個部分,然後拖動它(左或右,無所謂),然後釋放它。這不會調用didSelectRowAtIndexPath,因爲它不是水龍頭。
例子:
刷卡上indexpath A.1
輕按indexpath B.4
OS調用的tableView:didSelectRowAtIndexPath方法:A.1
難道我做錯了什麼?有什麼可能出錯?
,處理觸摸在特定細胞的完整代碼:
- (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;
}
您的問題,目前還不清楚十歲上下。您能否給出源代碼示例?另外,你是什麼意思的「刷卡」?你的意思是選擇或刪除? – 2010-07-09 02:00:42