Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9209047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:45:02+00:00 2026-06-18T00:45:02+00:00

I’m not exactly sure what’s going on and hope that I can provide enough

  • 0

I’m not exactly sure what’s going on and hope that I can provide enough relevant code to find an answer. I’ve set up my gesture recognizer in my appDelegate.m:

CCScene *scene = [HomeLayer scene];
HomeLayer *layer = (HomeLayer *) [scene.children objectAtIndex:0];

UIPanGestureRecognizer *gestureRecognizer = [[[UIPanGestureRecognizer alloc] initWithTarget:layer action:@selector(handlePanFrom:)] autorelease];
[director_.view addGestureRecognizer:gestureRecognizer];
m._gestureRecognizer = gestureRecognizer;

I’ve inserted some debugging messages to try to pinpoint at what point the app crashes:

- (void)handlePanFrom:(UIPanGestureRecognizer *)recognizer {
    NSLog(@"Handle Pan From");

as well as some printouts for ccTouchBegan/Moved/Ended.

Every time the app crashes, it’s while things are “moving”, (ended never gets called), and handlePanFrom never gets called either.

Background info: My app has buttons that I use to switch between scenes, for example:

- (void) doSomethingThree: (CCMenuItem  *) menuItem
{
    NSLog(@"The third menu was called");
    [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:[HomeLayer scene] ]];
}

If I start up my app and go directly to the HomeLayer scene, and try to drag, the app crashes instantly 100% of the time (ccMoved gets called 1-2 times before crash). Clicking does not cause the app to crash, only anything that would invoke handlePanFrom.

The strange thing is that if I drag around on any other scene, the app does not crash, and handlePanFrom successfully gets called. Then, when I go back to the HomeLayer scene and drag around, it won’t crash for some time, and it seems directly related to how long I spend dragging around on a different scene.

Has anyone seen these symptoms before? I’m not sure if the information I provided is relevant or correct, I’m still trying to learn my way around iphone dev. I’ll also be happy for any debugging tips (those assembly looking hex lines aren’t particularly enlightening to me…)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:45:03+00:00Added an answer on June 18, 2026 at 12:45 am

    I figured out the problem with the help of NSZombies, finding out that the program was crashing while trying to reference the deallocated method handlePanFrom.

    The ultimate root of the problem was that HomeLayer was being instantiated twice, the first time in appDelegate.m, and the 2nd time when i was doing the replaceScene.

    This resulted in the first layer eventually losing all of its references and being deallocated while the gestureRecognizer was still trying to reference [layer handlePanFrom], causing the crash.

    The problem was fixed by moving the gestureRecognizer from the appDelegate.m to HomeLayer.m, and for anyone who needs gestures across multiple layers, here’s a piece of code that will remove any existing references of the gestureRecognizer to the view, and then add a new one that targets a method in the layer:

    +(CCScene *) scene
    {
        HomeLayer *layer = [HomeLayer node];
    
        [scene addChild: layer];
    
        for (UIGestureRecognizer *gr in [[CCDirector sharedDirector].view gestureRecognizers]) {
            // note that sharedDirector is a singleton and therefore is the same CCDirector
            // as the one used in appDelegate.m
            [[CCDirector sharedDirector].view removeGestureRecognizer:gr];
        }
    
        UIPanGestureRecognizer *gestureRecognizer = [[[UIPanGestureRecognizer alloc] initWithTarget:layer action:@selector(handlePanFrom:)] autorelease];
    
        [[CCDirector sharedDirector].view addGestureRecognizer:gestureRecognizer];
    
        return scene;
    }
    

    Hopefully that may help someone in the future who is trying to work with multiple scenes/layers in a view =)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I need a function that will clean a strings' special characters. I do NOT
Seemingly simple, but I cannot find anything relevant on the web. What is the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a small JavaScript validation script that validates inputs based on Regex. I
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.