Il modo in cui ho risolto questo problema è in un modo che non è pulito, ma funziona. Per favore fatemi sapere se c'è un modo migliore per farlo.
Ho sostituito per la mia dogana UIView
in modo da indirizzare i tocchi allo UITableView
sottostante. Quindi nello UITableView
sto gestendo i gesti tramite touchesBegan
, touchesMoved
, ecc. Ci sto anche chiamando touchesBegan
su UIView
.
In questo modo i tocchi vengono gestiti da due visualizzazioni. Il motivo per cui non sto facendo il contrario (con 's) è che i riconoscimenti di gesti sullo UITableView
non funzionerebbero.
UIView
sottoclasse hitTest
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
// tview is the UITableView subclass instance
CGPoint tViewHit = [tView convertPoint:point fromView:self];
if ([tView pointInside:tViewHit withEvent:event]) return tView;
return [super hitTest:point withEvent:event];
}
UITableView
di sottoclasse touchesBegan
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:touch.view];
// ....
// view is the UIView's subclass instance
[view touchesBegan:touches withEvent:event];
}
fonte
2011-12-08 21:40:06
molto bello .. stavo cercando di fare dopo un po 'qualcosa di simile. Grazie per la pubblicazione. – riship89
Mi piace molto questo. Ho provato così tanto tempo a farlo nel modo sbagliato, chiamando manualmente TouchesBegan, ecc. Nella sottoview. Questo metodo funziona alla grande! – Gandalf458