0
我有一個子視圖的視圖。當輕觸子視圖中的按鈕時,子視圖將擴展到視圖邊界之外,並顯示其他兩個按鈕。但是,我找不到與他們互動的方式。如何使邊界外的子視圖識別觸摸
我發現了一個代碼,在蘋果公司的網站:
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
// Convert the point to the target view's coordinate system.
// The target view isn't necessarily the immediate subview
CGPoint pointForTargetView = [self.targetView convertPoint:point fromView:self];
if (CGRectContainsPoint(self.targetView.bounds, pointForTargetView)) {
// The target view may have its view hierarchy,
// so call its hitTest method to return the right hit-test view
return [self.targetView hitTest:pointForTargetView withEvent:event];
}
return [super hitTest:point withEvent:event];
}
不過,我不明白我應該如何使用它,讓自己的子視圖將識別觸摸。
任何幫助將grely讚賞。