You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/05/09 05:54:46 UTC

[2/7] incubator-weex git commit: * [ios] fix scan history tap gesture conflict

* [ios] fix scan history tap gesture conflict


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/fe8e478e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/fe8e478e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/fe8e478e

Branch: refs/heads/dev
Commit: fe8e478ef626b1ad746f43f7ce0d62d2f1479c1b
Parents: cb527b0
Author: acton393 <zh...@gmail.com>
Authored: Fri Apr 28 15:16:46 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Fri Apr 28 15:16:46 2017 +0800

----------------------------------------------------------------------
 .../WeexDemo/Scanner/WXScannerHistoryVC.m       | 25 ++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/fe8e478e/ios/playground/WeexDemo/Scanner/WXScannerHistoryVC.m
----------------------------------------------------------------------
diff --git a/ios/playground/WeexDemo/Scanner/WXScannerHistoryVC.m b/ios/playground/WeexDemo/Scanner/WXScannerHistoryVC.m
index 984d8ea..9d71314 100644
--- a/ios/playground/WeexDemo/Scanner/WXScannerHistoryVC.m
+++ b/ios/playground/WeexDemo/Scanner/WXScannerHistoryVC.m
@@ -42,6 +42,7 @@
     [self setupNaviBar];
     UITapGestureRecognizer * tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleClick:)];
     [self.tableView addGestureRecognizer:tapGestureRecognizer];
+    tapGestureRecognizer.delegate = self;
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadHistory) name:NSUserDefaultsDidChangeNotification object:nil];
 }
 
@@ -71,6 +72,7 @@
     }
     UILongPressGestureRecognizer * longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
     longPressGesture.minimumPressDuration = 1.0;
+    longPressGesture.delegate = self;
     [cell addGestureRecognizer:longPressGesture];
     NSMutableAttributedString * attributeString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%ld %@",(long)indexPath.row+1,[_scanner_history objectAtIndex:indexPath.row]]];
     [attributeString addAttribute:(NSString*)NSForegroundColorAttributeName value:(id)[UIColor redColor].CGColor range:NSMakeRange(0, 1)];
@@ -95,7 +97,8 @@
     }
 }
 
-- (void)reloadHistory {
+- (void)reloadHistory
+{
     if ([_scanner_history count]) {
         [_qrCodeImageView removeFromSuperview];
         [_scanner_history removeAllObjects];
@@ -103,15 +106,29 @@
     }
 }
 
-- (void)handleClick:(UITapGestureRecognizer*)gestureRecognizer {
+- (void)handleClick:(UITapGestureRecognizer*)gestureRecognizer
+{
     CGPoint clickPoint = [gestureRecognizer locationInView:self.tableView];
     if (!CGRectContainsPoint(_qrCodeImageView.frame, clickPoint)) {
         [_qrCodeImageView removeFromSuperview];
     }
-    
 }
 
-- (void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer {
+- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
+{
+    if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]) {
+        if ([_qrCodeImageView superview]) {
+            return YES;
+        }
+    }
+    if ([gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]]) {
+        return YES;
+    }
+    return NO;
+}
+
+- (void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer
+{
     if (gestureRecognizer.state != UIGestureRecognizerStateBegan) {
         return ;
     }