iphone - App crashing when trying to implement UILongPressGesture -


i'm trying implement uilongpressgesture on 1 of tables in order able reorder cells. however, every time long-press app crashes.

here's file implements uilongpressgesture:

#import "lstrtableviewdragtomove.h" #import "lstrtableviewcell.h"  @implementation lstrtableviewdragtomove {     lstrtableview *_tableview;     bool _draginprogress;     cgpoint _initialtouchpoint;     int _cellindex;     lstrtableviewcell *_currentcell;  }  -(id)initwithtableview:(lstrtableview *)tableview {     self = [super init];     if(self)     {         _tableview = tableview;         uigesturerecognizer *recognizer = [[uilongpressgesturerecognizer alloc] initwithtarget:self action:@selector(handlelongpress:)];         [_tableview addgesturerecognizer:recognizer];     }      return self;  }  -(bool) viewcontainspoint:(uiview*)view withpoint:(cgpoint)point {     cgrect frame = view.frame;     return (frame.origin.y < point.y) && (frame.origin.y + frame.size.height) > point.y; }  -(void)handlelongpress:(uilongpressgesturerecognizer *)recognizer {     if (recognizer.state == uigesturerecognizerstatebegan) {         [self longpressstarted:recognizer];     }      if (recognizer.state == uigesturerecognizerstateended) {         [self longpressended:recognizer];     } }  -(void)longpressstarted:(uilongpressgesturerecognizer *)recognizer {     nslog(@"started");     /*     _initialtouchpoint = [recognizer locationoftouch:0 inview:_tableview.scrollview];     nsarray* visiblecells = _tableview.visiblecells;     (int i=0; < visiblecells.count; i++) {         uiview* cell = (uiview*)visiblecells[i];         if ([self viewcontainspoint:cell withpoint:_initialtouchpoint]) {             _cellindex = i;         }     }      _currentcell = _tableview.visiblecells[_cellindex];     _currentcell.label.allowseditingtextattributes = no;     _currentcell.frame = cgrectmake(_currentcell.frame.origin.x, _currentcell.frame.origin.y, _currentcell.frame.size.width + 10.0f, _currentcell.frame.size.height + 10.0f);     [_currentcell adddropshadow];      */ }   -(void)longpressended:(uilongpressgesturerecognizer *)recognizer {     nslog(@"ended"); }  @end 

and here's error log:

2013-05-03 13:17:53.750 lstr[19207:907] -[uilongpressgesturerecognizer translationinview:]: unrecognized selector sent instance 0x20856240 2013-05-03 13:17:53.754 lstr[19207:907] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[uilongpressgesturerecognizer translationinview:]: unrecognized selector sent instance 0x20856240' *** first throw call stack: (0x3302a2a3 0x3ad5297f 0x3302de07 0x3302c531 0x3302d938 0x6db43 0x34f4f1ab 0x34f1863f 0x34f482a5 0x33941f53 0x32fff5df 0x32fff291 0x32ffdf01 0x32f70ebd 0x32f70d49 0x36b492eb 0x34e86301 0x66775 0x3b189b20) libc++abi.dylib: terminate called throwing exception (lldb) 

thanks in advance.

update:

here's method has translationinview:

#pragma mark - horizontal pan gesture methods -(bool)gesturerecognizershouldbegin:(uipangesturerecognizer *)gesturerecognizer {     cgpoint translation = [gesturerecognizer translationinview:[self superview]];     // check horizontal gesture     if (fabsf(translation.x) > fabsf(translation.y)) {         return yes;     }     return no; } 

are using translationinview somewhere in code?

you should change locationinview:


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -