我正在尝试显示第 3 方 UIView,它基本上包含带有一些可点击(可触摸)区域的图像。例如,它包含一个区域,单击该区域时会启动一个网页。我为此创建了一个 UIViewController,它应该将此 UIView 显示为全屏。我知道图像的宽度和高度,所以我需要缩放这个视图以适应全屏。
这是我的问题:当我尝试缩放图像时,子视图中的可点击区域不再可点击。
这是我进行缩放的方式:
float scalingFactor = (adAspectRatio > deviceAspectRatio) ? deviceWidth / adWidth : deviceHeight / adHeight;
float scaledWidth = adWidth * scalingFactor;
float scaledHeight = adHeight * scalingFactor;
adFrame = CGRectMake((deviceWidth - scaledWidth) / 2.0f, (deviceHeight - scaledHeight) / 2.0f, adWidth, adHeight);
thirdpartyview.transform = CGAffineTransformScale(CGAffineTransformIdentity, scalingFactor, scalingFactor);
[thirdpartyview setFrame:adFrame];
...
[self.view addSubview:thirtpartyview];
在进行转换时,所有的触摸现在都转到我的视图控制器,而不是那个子视图。现在我不能点击任何东西。如果我不进行转换,或者我进行了转换但使用身份,一切正常,但它没有按我想要的方式缩放。当我变换时,它可以正确缩放,但触摸不起作用。
如果我尝试检测视图控制器上的触摸,我能够接收到触摸事件。但我不知道如何将触摸事件转发到第三方视图。
有什么建议么?