2016-04-25 5 views
0

私はコレクションビューの左上にボタンを追加するメソッドを持っています。問題は、私がlongPressRecognizer minimumPressDurationを0.0001のようなものに設定すると、ボタンをタップする代わりにlongPressRecognizerメソッドが有効になるため、ボタンをタップできなくなることです。見てみてください:ロングタップ認識機能の特定の領域を除外

UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd]; 

[[RACObserve(self, shouldEdit) deliverOnMainThread] subscribeNext:^(id x) { 

    UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd]; 
    if (self.shouldEdit){ 

     self.layout.longPressGestureRecognizer.minimumPressDuration = 0.1; 

     int ind = indexPath.row; 
     NSLog(@"1 blk called"); 
    button = [UIButton buttonWithType:UIButtonTypeContactAdd]; 
    [button addTarget:self 
       action:@selector(aMethod:) 
    forControlEvents:UIControlEventTouchUpInside]; 
    [button setTag:indexPath.row]; 
    [cell addSubview:button]; 

    [button mas_makeConstraints:^(MASConstraintMaker *make) { 

     make.left.equalTo(cell.mas_left).with.offset(0); 
     make.top.equalTo(cell.mas_top).with.offset(0); 
     make.width.height.equalTo(@(20)); 

    }]; 

    } 

は、私が反応ココアや石材を使用していますが、これは実際には関係ありません、私が欲しいのは、私がlongGestureRecognizerのために使用することができ、エリアからボタン領域を除外しています。

答えて

2

self.layout.longPressGestureRecognizer.minimumPressDuration = 0.1;

あなたはself.myview.longPressGestureRecognizer.minimumPressDuration = 0.1を使用できます。 myviewではmyviewにボタンを置かないでください。これでボタンをタップできます

関連する問題