このメソッドを持つマスターView Controllerがあります
- (void)revealGesture:(UIPanGestureRecognizer *)recognizer{
}
スワイプを使用して子ビューコントローラーからメッセージを送信すると機能します。
UIPanGestureRecognizer *navigationBarPanGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self.navigationController.parentViewController action:@selector(revealGesture:)];
[self.navigationController.navigationBar addGestureRecognizer:navigationBarPanGestureRecognizer];
子viewController内からメッセージを渡したいので、最初にハウスキーピングを行うことができます
UIPanGestureRecognizer *navigationBarPanGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(revealGesture:)];
[self.navigationController.navigationBar addGestureRecognizer:navigationBarPanGestureRecognizer];
と
- (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];
}
はい、私がしようとしているのは、「self.navigationController.parentViewController」を直接ターゲットにするだけで正常に機能するコードを実行する前に、キーボードを閉じることだけです
(UIPanGestureRecognizer *) 認識機能を NSDictionary に追加するにはどうすればよいですか?
私のコードはでクラッシュします
-[__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'
編集提案された解決策は機能しましたが、キーボードが応答しませんでした。行を変更する必要がありました
[self searchBarCancelButtonClicked:searchBar];
searchBar は UISearchBar のインスタンスです