DZNEmptyDataSet
DZNEmptyDataSet copied to clipboard
the custom view cannot respond to the click event. I modify a method work as well
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
it is work for me, thx!
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 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?