2010-08-13 22 views

risposta

90

Impostare UIView.exclusiveTouch.

+0

Fantastico! Perché non ci ho pensato per i pulsanti che non conosco ?! – pryomoax

+4

Perfetto! era come un tesoro nascosto, non ho mai saputo di questa proprietà, grazie mille. – RVN

+8

si prega di notare per impostarlo su ogni "UIButton"! NOT the UIView quei pulsanti sono in :) (Impostare su tutti i sottoview di quello che farebbe UIView) come questo -> [self.controlView.subviews makeObjectsPerformSelector: @selector (setExclusiveTouch :) withObject: [NSNumber numberWithBool: YES] ]; – Hlung

11

È inoltre possibile utilizzare il metodo seguente. Se hai due o più pulsanti, per evitare più push alla volta.

per esempio,

[Button1 setExclusiveTouch:YES]; 

[Button2 setExclusiveTouch:YES]; 

Impostare questo metodo nella viewDidLoad o viewWillAppear

2
for(UIView* v in self.view.subviews) 
    { 
    if([v isKindOfClass:[UIButton class]]) 
    { 
     UIButton* btn = (UIButton*)v; 
     [yourButton setExclusiveTouch:YES]; 
    } 
} 
0

Hai bisogno di trovare tutti i pulsanti su quella vista e impostare il "exclusiveTouch" proprietà vero per evitare il multi-touch allo stesso tempo.

func exclusiveTouchForButtons(view: UIView) { 
    for cmp in view.subviews { 
     if let cmpButton = cmp as? UIButton { 
      cmpButton.exclusiveTouch = true 
     } else { 
      exclusiveTouchForButtons(cmp) 
     } 
    } 
} 
Problemi correlati