Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 主视图之外的子视图不接收触摸事件_Iphone_Objective C_Uiview - Fatal编程技术网

Iphone 主视图之外的子视图不接收触摸事件

Iphone 主视图之外的子视图不接收触摸事件,iphone,objective-c,uiview,Iphone,Objective C,Uiview,在我的应用程序中,我有一个主屏幕,它有一个子视图(这是另一个屏幕),但是这个子视图向右移动了320,所以它只是在屏幕外。其效果是主屏幕向左移动320,从而隐藏主屏幕并显示另一个屏幕,因为它是子视图。问题是,另一个屏幕没有接收触摸事件,因为它超出了主屏幕(superview)的范围。如何让另一个屏幕也接收触摸事件,以便我可以点击按钮?请查看相关说明。解决方案是使用以下代码实现您自己的hitTest: - (BOOL)pointInside:(CGPoint)point withEvent:(UIE

在我的应用程序中,我有一个主屏幕,它有一个子视图(这是另一个屏幕),但是这个子视图向右移动了320,所以它只是在屏幕外。其效果是主屏幕向左移动320,从而隐藏主屏幕并显示另一个屏幕,因为它是子视图。问题是,另一个屏幕没有接收触摸事件,因为它超出了主屏幕(superview)的范围。如何让另一个屏幕也接收触摸事件,以便我可以点击按钮?

请查看相关说明。解决方案是使用以下代码实现您自己的hitTest:

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {

    BOOL isInside = [super pointInside:point withEvent:event];

    // identify the button view subclass
    UIButton *b = (UIButton *)[self viewWithTag:3232];
    CGPoint inButtonSpace = [self convertPoint:point toView:b];

    BOOL isInsideButton = [b pointInside:inButtonSpace withEvent:nil];

    if (YES == isInsideButton) {

       return isInsideButton;

    } // if (YES == isInsideButton)

    return isInside;
 }

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

    UIView *v = nil;

    v = [super hitTest:point withEvent:event];

    return v;
 }