簡體   English   中英

在自定義UIViewController中檢測多點觸摸,其中包含UITableView子視圖

[英]Detect multitouch in a custom UIViewController contains a UITableView subview

我在UIViewController的視圖中有一個UITableView作為子視圖。 我了解我可以通過改寫來檢測觸摸事件

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesBegan:touches withEvent:event];
}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesEnded:touches withEvent:event];
}

-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesCancelled:touches withEvent:event];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesMoved:touches withEvent:event];  
}

但是如果我觸摸tableview它就不會在ViewController檢測到這些事件。 正如其他人在該論壇中所建議的那樣,我應該有一個自定義UITableView並在其中添加了以上UITableView行。 我這樣做了,但是viewController仍然沒有檢測到touch事件。 有什么建議么? 謝謝。

經過幾天的谷歌搜索,我終於找到了適合我的解決方案。 關鍵是將響應者鏈傳遞給下一個響應者。 例如,在觸摸開始的情況下,添加以下行。 [self.nextResponder touchesBegan:toucheswithEvent:event]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM