pass uigesturerecognzer data to parent controller

There is a master view controller with this method

- (void)revealGesture:(UIPanGestureRecognizer *)recognizer{ 
}

which works when I send it a mesage froma child viewcontroller using a swipe:

UIPanGestureRecognizer *navigationBarPanGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self.navigationController.parentViewController action:@selector(revealGesture:)];
[self.navigationController.navigationBar addGestureRecognizer:navigationBarPanGestureRecognizer];

I want to pass the message on from within the child viewController so I can do some house keeping first

    UIPanGestureRecognizer *navigationBarPanGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(revealGesture:)];
    [self.navigationController.navigationBar addGestureRecognizer:navigationBarPanGestureRecognizer];

and

- (void)revealGesture:(UIPanGestureRecognizer *)recognizer
{
    [displaySearch resignFirstResponder];
    RevealController *revealController = [self.navigationController.parentViewController isKindOfClass:[RevealController class]] ? (RevealController *)self.navigationController.parentViewController : nil;

    NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys: recognizer, @"recognizer", nil];

    [revealController performSelector:@selector(revealGesture:) withObject:data];
}

Yes, all I'm trying to do is dismiss the keyboard before carrying on with a bit of code that works fine if I just target 'self.navigationController.parentViewController' directly

How do I add (UIPanGestureRecognizer *)recognizer to the NSDictionary?

My code crashes with

-[__NSCFDictionary state]: unrecognized selector sent to instance 0x8619860
2013-05-02 21:12:05.752 PwC UK[57884:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary state]: unrecognized selector sent to instance 0x8619860'

EDIT Proposed solution worked but keyboard didn't respond, needed to chage the line to

[self searchBarCancelButtonClicked:searchBar];

where searchBar is instance of UISearchBar

Answers


It looks like revealGesture is expecting a UIPanGestureRecognizer as its parameter but you are passing an NSDictionary. Try passing the gesture recognizer directly.

[revealController performSelector:@selector(revealGesture:) withObject: recognizer];

Need Your Help

How do I create this shape in SVG?

svg d3.js bar-chart

Right now, I have my bar bases styled as shadows using ellipses.: http://jsfiddle.net/rdesai/MjFgK/55/

Missing javascript file, expressJS on dotcloud “failed to load resource.” Routing issue?

node.js routing express dotcloud

I deployed an express app to dotcloud, and I get an error here: http://valgomat-nilsnh.dotcloud.com/valgomat . All my other javascript files included in the html seem to get loaded except