DZNEmptyDataSet icon indicating copy to clipboard operation
DZNEmptyDataSet copied to clipboard

the custom view cannot respond to the click event. I modify a method work as well

Open yanyanforest opened this issue 6 years ago • 3 comments

I find that the custom view for delegate method - (UIView *)customViewForEmptyDataSet:(UIScrollView *)scrollView... reasons:as I think class DZNEmptyDataSetView implements method - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event .it wirte this:

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
    UIView *hitView = [super hitTest:point withEvent:event];
    
    // Return any UIControl instance such as buttons, segmented controls, switches, etc.
    if ([hitView isKindOfClass:[UIControl class]]) {
        return hitView;
    }
    
    // Return either the contentView or customView
    if ([hitView isEqual:_contentView] || [hitView isEqual:_customView]) {
        return hitView;
    }
  
    return nil;
}

then no any response, so I modify this method add if statement,

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
    UIView *hitView = [super hitTest:point withEvent:event];
    
    // Return any UIControl instance such as buttons, segmented controls, switches, etc.
    if ([hitView isKindOfClass:[UIControl class]]) {
        return hitView;
    }
    
    // Return either the contentView or customView
    if ([hitView isEqual:_contentView] || [hitView isEqual:_customView]) {
        return hitView;
    }
    if ([hitView isKindOfClass:[DZNEmptyDataSetView class]]) {
        return hitView;
    }
    return nil;
}

so has response,works as well

yanyanforest avatar Jun 13 '18 08:06 yanyanforest

it is work for me, thx!

kirinzer avatar Sep 03 '18 09:09 kirinzer

I find the really reason, customView lost a constraints in the below function. - (void)setupConstraints I suggest u change the version to v1.6.1, everything is ok!

kirinzer avatar Sep 03 '18 10:09 kirinzer

@kirinzer how you change the function - (void)setupConstraints?

I do like this in this method 'if (_customView) { CGFloat height = _customView.bounds.size.height; [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[customView]|" options:0 metrics:nil views:@{@"customView":_customView}]]; [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[customView(==height)]|" options:0 metrics:@{@"height":@(height)} views:@{@"customView":_customView}]]; }'. about you?

yanyanforest avatar Sep 17 '18 02:09 yanyanforest