मैं बहुत तरह cellForRowAtIndexPath:
विधि में एक एक UITableViewCell
करने के लिए UISwipeGestureRecognizer
संलग्न कर रहा हूँ:UIGestureRecognizer और UITableViewCell मुद्दा
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipe:)];
gesture.direction = UISwipeGestureRecognizerDirectionRight;
[cell.contentView addGestureRecognizer:gesture];
[gesture release];
}
return cell;
}
हालांकि, didSwipe
विधि हमेशा दो बार सफल कड़ी चोट पर कहा जाता हो रही है। मैं शुरू में सोचा था इस वजह से इशारा प्रारंभ और समाप्त होता था, लेकिन अगर मैं gestureRecognizer ही लॉग आउट, वे "समाप्त" राज्य में दोनों कर रहे हैं:
-(void)didSwipe:(UIGestureRecognizer *)gestureRecognizer {
NSLog(@"did swipe called %@", gestureRecognizer);
}
कंसोल:
2011-01-05 12:57:43.478 App[20752:207] did swipe called <UISwipeGestureRecognizer: 0x5982fa0; state = Ended; view = <UITableViewCellContentView 0x5982c30>; target= <(action=didSwipe:, target=<RootViewController 0x5e3e080>)>; direction = right>
2011-01-05 12:57:43.480 App[20752:207] did swipe called <UISwipeGestureRecognizer: 0x5982fa0; state = Ended; view = <UITableViewCellContentView 0x5982c30>; target= <(action=didSwipe:, target=<RootViewController 0x5e3e080>)>; direction = right>
मैं वास्तव में वास्तव में पता नहीं क्यों। मैंने स्पष्ट रूप से समाप्त राज्य की जांच करने की कोशिश की, लेकिन यह कोई मदद नहीं है क्योंकि वे दोनों "समाप्त" के रूप में आते हैं ... कोई विचार?
धन्यवाद! इसने इसे दो बार फायरिंग से रोक दिया! :) – mootymoots
धन्यवाद, इससे मदद मिली, लेकिन मैं कुछ अजीब देख रहा हूं - स्वाइप करने के बाद मुझे पंक्ति का चयन करना चाहते हैं तो मुझे दो बार दबाएं। पहली बार कुछ भी नहीं करता है, और दूसरी कॉल करता है चयन करें ... किसी ने इसे देखा है? –
@OdedBenDov मेरा मानना है कि यह इशारा पहचानकर्ता के कारण होता है, मेरे पास तालिका दृश्य सेल चयन के लिए अजीब व्यवहार था जब मैंने टैप इशारा पहचानकर्ता जोड़ा और टेक्स्ट फ़ील्ड (टेबल व्यू सेल के उप दृश्य) की अंत संपादन विधि में निकालना भूल गया, शायद यह आपकी समस्या को हल करने के लिए एक सुराग के रूप में कार्य कर सकता है, अधिक जानकारी [यहां] (http://stackoverflow.com/questions/9939509/strange-behavior-did-select-row-touch-not-responding-for-uitableviewcell) –