很簡單的問題,或許不是那麼簡單的答案,但:如何將觸摸傳遞給另一個視圖下方的按鈕?
我已經清楚地看到需要接觸的部分。 下面這是一個UIButton,我也想要接觸(因爲我不會進入的原因,它必須在下面)。在按下按鈕的情況下,我不希望清晰的視圖接收觸摸。
我怎樣才能做到這一點?
編輯:
最終解決方案:
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
for (UIView * view in self.subviews)
{
if ([view isKindOfClass:[UIButton class]]) {
CGPoint pointInButton = [view convertPoint:point fromView:self];
if ([view pointInside:pointInButton withEvent:event]) {
return view;
}
}
}
return [super hitTest:point withEvent:event];
}
你有沒有嘗試過爲你的清晰視圖設置'userInteractionEnabled'爲false? – aroth 2012-01-04 02:33:06
@aroth我也需要清晰的觀點才能接觸到。對不起,應該在問題中更具體(我現在將編輯)。 – 2012-01-04 02:34:36