From b25ff5c2e679d945d3e588eaee2f61b9c1b29283 Mon Sep 17 00:00:00 2001 From: johnkdoe Date: Sun, 24 Feb 2013 11:37:25 -0800 Subject: [PATCH] fix an issue where leaving the app & coming back in would ignore keyboard --- FPPopoverController.m | 6 +++--- FPTouchView.m | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/FPPopoverController.m b/FPPopoverController.m index 7c25314..b4239b5 100644 --- a/FPPopoverController.m +++ b/FPPopoverController.m @@ -88,8 +88,9 @@ -(id)initWithViewController:(UIViewController*)viewController _touchView.backgroundColor = [UIColor clearColor]; _touchView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; _touchView.clipsToBounds = NO; + [_touchView becomeFirstResponder]; [self.view addSubview:_touchView]; - + __block typeof (self) bself = self; [_touchView setTouchedOutsideBlock:^{ [bself dismissPopoverAnimated:YES]; @@ -99,9 +100,8 @@ -(id)initWithViewController:(UIViewController*)viewController _contentView = [[FPPopoverView alloc] initWithFrame:CGRectMake(0, 0, self.contentSize.width, self.contentSize.height)]; - _viewController = viewController; - + [_touchView addSubview:_contentView]; [_contentView addContentView:_viewController.view]; diff --git a/FPTouchView.m b/FPTouchView.m index dd30cb5..e68d2a7 100644 --- a/FPTouchView.m +++ b/FPTouchView.m @@ -10,7 +10,6 @@ @implementation FPTouchView - -(void)setTouchedOutsideBlock:(FPTouchedOutsideBlock)outsideBlock { _outsideBlock = outsideBlock; @@ -21,6 +20,11 @@ -(void)setTouchedInsideBlock:(FPTouchedInsideBlock)insideBlock _insideBlock = insideBlock; } +- (BOOL)canBecomeFirstResponder +{ + return YES; +} + -(UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event { UIView *subview = [super hitTest:point withEvent:event]; @@ -45,7 +49,7 @@ -(UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event { _insideBlock(); } - else if(!touchedInside && _outsideBlock) + else if(self.isFirstResponder && !touchedInside && _outsideBlock) { _outsideBlock(); }