SORU
7 Mart 2011, PAZARTESİ


UİGestureRecognizer blok dokunma olayları işlemek için küme

Bu işin nasıl olduğunu anlamaya çalışıyorumdoğru yolu. Durumu tasvir etmeye çalıştım: enter image description here

Bir UİView bir küme olarak bir UİTableView ekliyorum. Bu UİView dokunun ve pinchGestureRecognizer bir tepki verir, ama bunu yaparken tableview bu iki hareketleri için (hala dokunuşa tepki) tepki vermiyor.

Bunu aşağıdaki kod ile iş yaptım, ama belli ki iyi bir çözüm değil ve daha iyi bir yolu yoktur eminim. Bu UİView (superview) konur:

-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
    if([super hitTest:point withEvent:event] == self) {
        for (id gesture in self.gestureRecognizers) {
            [gesture setEnabled:YES];
        }
        return self;
    }
    for (id gesture in self.gestureRecognizers) {
        [gesture setEnabled:NO];
    }
    return [self.subviews lastObject];
}

CEVAP
20 Temmuz 2012, Cuma


Subviews için dokunmatik olayları engelleme varsayılan davranıştır. Bu davranışı değiştirebilirsiniz:

    UITapGestureRecognizer *r = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(agentPickerTapped:)];
    r.cancelsTouchesInView = NO;
    [agentPicker addGestureRecognizer:r];

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Doug Bernards

    Doug Bernard

    7 Kasım 2007
  • DrakeVEVO

    DrakeVEVO

    17 AĞUSTOS 2009
  • theatre2film

    theatre2film

    12 NİSAN 2006