0

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

Bobyblanco
  • 123
  • 12
  • can you post the code for the "transitionCubeLeft"/"transitionCubeLeft" methods? off topic: please take care of your memory management: http://stackoverflow.com/a/5932733/644629 – CarlJ Apr 17 '12 at 11:37
  • Also, what's the name of the class your posted code is in and what is its parent class? – Phillip Mills Apr 17 '12 at 11:39
  • the two function transition `-(void)transitionCubeRight{ NSLog(@"RIGHT"); borne=angle+90; } -(void)transitionCubeLeft{ NSLog(@"LEFT"); borne=angle-90; }` – Bobyblanco Apr 17 '12 at 12:23
  • @philip Mills The parent class is UIView, but i had the same problem when i tried to put all that code in my viewController – Bobyblanco Apr 17 '12 at 12:24

2 Answers2

2

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.

Martin Pilch
  • 3,245
  • 3
  • 38
  • 61
  • it was the problem :s Actually I put ":" because i needed one parameter but after a while i decided not to put this parameter and i forgot to delete the ":" Thanks again ! Sometimes the most obvious mistakes are the hardest to find – Bobyblanco Apr 17 '12 at 12:26
  • @Bobyblanco now you will remember it for the rest of your life :) – Martin Pilch Apr 17 '12 at 13:07
1

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];
Rok Jarc
  • 18,765
  • 9
  • 69
  • 124