2016-04-25 27 views
0

我有一个方法,在我的收藏视图单元格的左上角添加按钮和longPress识别器。问题是,当我将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.by这个你可以点击按钮