It did work as it should in my previous project but all of a sudden it throws exception and I've compared two, can't really figure out because both situations are identical.
This is what I'm getting -
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UISwipeGestureRecognizer toggleMenu:]: unrecognized selector sent to instance 0x7fb663f3cda0'
In OptionView.m
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(toggleMenu:) name:@"toggleMenuYes" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(toggleMenu:) name:@"toggleMenuNo" object:nil];
-(void)toggleMenu:(NSNotification *)shouldOpenMenu{
[self.animator removeAllBehaviors];
NSString *one = @"1";
if (shouldOpenMenu.object == one) {
NSLog(@"yes");
self.yesOrNo = YES;
}
else {
self.yesOrNo = NO;
}
}
In myVC.m
UISwipeGestureRecognizer *showMenuGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self
action:@selector(handleGesture:)];
showMenuGesture.direction = UISwipeGestureRecognizerDirectionRight;
[self.optionViewCell addGestureRecognizer:showMenuGesture];
showMenuGesture.delegate = self;
UISwipeGestureRecognizer *hideMenuGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self
action:@selector(handleGesture:)];
hideMenuGesture.direction = UISwipeGestureRecognizerDirectionLeft;
[self.optionViewCell addGestureRecognizer:hideMenuGesture];
hideMenuGesture.delegate = self;
-(void)handleGesture:(UISwipeGestureRecognizer *)gesture{
if (gesture.direction == UISwipeGestureRecognizerDirectionRight) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"toggleMenuYes" object:@"1"];
}
else{
[[NSNotificationCenter defaultCenter] postNotificationName:@"toggleMenuNo" object:@"0"];
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire