使用xib制作界面有时会出现button无法点击,解决办法

时间:2021-10-10 14:52:17

在view文件中复制如下代码

//解决苹果4S头视图超出了屏幕大小button不能点击问题

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {

    UIView *result = [super hitTest:point withEvent:event];

    CGPoint buttonPoint2 = [self.Button convertPoint:point fromView:self];

 

    if ([self.Button pointInside:buttonPoint2 withEvent:event]) {

        return self.Button;

    }

   

    return result;

}