2016-04-25 29 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這個你可以點擊按鈕