我正在尝试创建iPad应用程序,它有两个UIView
s(如UISplitView
)。 “主”方面有UISearchDisplayController
。
我需要通过点击外部(“主”或“细节”侧)来解除键盘。现在我只能通过点击其中的关闭按钮或点击UISearchDisplayController
来解除键盘。
已解决:
@interface MyViewController : UIViewController <UIGestureRecognizerDelegate>
...
...
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard:)];
tapGesture.delegate = self;
[self.view addGestureRecognizer:tapGesture];
...
...
- (void)dismissKeyboard:(UITapGestureRecognizer *)sender
{
if (sender.state == UIGestureRecognizerStateEnded) {
self.searchDisplayController.active = NO;
}
}