Reputation: 6965
I have a method that add button on top-left of my collection view cell, and longPress recognizer. The problem is, when i set longPressRecognizer minimumPressDuration to something like 0.0001, i cant tap a button, because, instead of tapping button activates longPressRecognizer method. Please take a look:
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));
}];
}
I use reactive cocoa and masonry, but this actually doesn't matter, what i want is exclude button area from area, that i can use for longGestureRecognizer
.
Upvotes: 0
Views: 47
Reputation: 485
self.layout.longPressGestureRecognizer.minimumPressDuration = 0.1;
you can use self.myview.longPressGestureRecognizer.minimumPressDuration = 0.1; and in myview don't place button in myview.by this you can able to tap button
Upvotes: 2