views:

214

answers:

1

now i'm working with cocos2d and i design to add navigationcontroller to my cocos2d application, so i add navigationcontroller to my application when i click it not pass touch or event to cocos2d

now i'm try to override UINavigationController by add new new class name is NavigationController and inherit from UINavigationController

in init i call [super init]; every things look be ok

but when i try to add

- (BOOL)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"Im overriding touch");
    return YES;

}



- (BOOL)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"Im overriding touchMove");
    return YES;
}

it not call

A: 

Why are you calling the methods ccTouchesBegan:withEvent: and ccTouchesMoved:withEvent: instead of the original names? You don't have to change the names of the methods when you subclass UINavigationController; instead, you should keep the same names and call super on them as well as appropriate. For example:

- (BOOL)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"I'm overriding touch");
    return [super touchesBegan:touches withEvent:event];
}

- (BOOL)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"I'm overriding move");
    return [super touchesMoved:touches withEvent:event];
}
Tim
thank you Timit work correctly,i'm copy code from cocos2d code that make me got a incorrect name of method
RAGOpoR
If it worked correctly, you can accept this answer by clicking the green checkmark under the answer's score. This lets other people know what to do if they run into the same problem as you.
Tim