Question

I'm asking for your help for i think a simple problem but i didn't manage to understand what's happening with my view. I'm displaying an OpengGL view launched by my UIViewController like this:

  //OpenGL view init
CGRect mainframe=CGRectMake(0,0,768,708);
GLView= [[OpenGLView alloc] initWithFrame:mainframe];

So then it is displayed well, but i tried to add a swipe gesture recognizer to call a function on this view:

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {

        ...  

        oneFingerSwipeRight =[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(transitionCubeRight:)];
        oneFingerSwipeRight.direction=UISwipeGestureRecognizerDirectionRight;

        oneFingerSwipeLeft =[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(transitionCubeLeft:)];
        oneFingerSwipeLeft.direction=UISwipeGestureRecognizerDirectionLeft;

        [self addGestureRecognizer:oneFingerSwipeRight];
        [self addGestureRecognizer:oneFingerSwipeLeft];

        ...
    }
    return self;
}

And then when the view appear, i'm doing the action swiping on the right or on the left and this appear in the terminal:

2012-04-17 12:00:15.735 MultipleViewsApp[4372:f803] -[OpenGLView transitionCubeLeft:]: unrecognized selector sent to instance 0xcd38bd0 2012-04-17 12:00:15.736 MultipleViewsApp[4372:f803] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[OpenGLView transitionCubeLeft:]: unrecognized selector sent to instance 0xcd38bd0' First throw call stack: (0x1764052 0x18f5d0a 0x1765ced 0x16caf00 0x16cace2 0x622e39 0x622143 0x6233cf 0x625a31 0x62598c 0x61e3e7 0x386812 0x386ba2 0x36d384 0x360aa9 0x293dfa9 0x17381c5 0x169d022 0x169b90a 0x169adb4 0x169accb 0x293c879 0x293c93e 0x35ea9b 0x2518 0x2475)

my functions "transitionCubeLeft"/"transitionCubeLeft" contains just an NSLOG but nothing else relevant for this. I'll be very gratefull if someone could help me to understand this problem. thankss

Was it helpful?

Solution

It looks like you have transitionCubeLeft/transitionCubeRight defined without parameters.

Change

 oneFingerSwipeRight =[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(transitionCubeRight:)];
 oneFingerSwipeRight.direction=UISwipeGestureRecognizerDirectionRight;

 oneFingerSwipeLeft =[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(transitionCubeLeft:)];
 oneFingerSwipeLeft.direction=UISwipeGestureRecognizerDirectionLeft;

 [self addGestureRecognizer:oneFingerSwipeRight];
 [self addGestureRecognizer:oneFingerSwipeLeft];

to

 oneFingerSwipeRight =[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(transitionCubeRight)];
 oneFingerSwipeRight.direction=UISwipeGestureRecognizerDirectionRight;

 oneFingerSwipeLeft =[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(transitionCubeLeft)];
 oneFingerSwipeLeft.direction=UISwipeGestureRecognizerDirectionLeft;

 [self addGestureRecognizer:oneFingerSwipeRight];
 [self addGestureRecognizer:oneFingerSwipeLeft];

OTHER TIPS

I guess you have not defined transitionCubeLeft method. Try to find out if it is defined and the count of parameters of the method is 1, according to the selecter you are using.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top