Pregunta

Tengo que llamar a eventos táctiles en el iPhone cuando hace clic en un botón.  tengo el siguiente código que no está llamando evento táctil

Por favor, cualquiera que me haga saber cómo resolver esto.

El código del botón es el siguiente.

- método (void) {

BottomView = [[UIView alloc] init];

btnRefresh = [UIButton buttonWithType: UIButtonTypeCustom];     [BtnRefresh setImage: [UIImage imageNamed: @ "refresh_icon.png"] forState: UIControlStateNormal];     [BtnRefresh setBackgroundImage: [[UIImage imageNamed: @ "blue.png"] stretchableImageWithLeftCapWidth: 12,0 topCapHeight: 0,0] forState: UIControlStateNormal];     [BtnRefresh setBackgroundImage: [[UIImage imageNamed: @ "ggrey1.png"] stretchableImageWithLeftCapWidth: 12,0 topCapHeight: 0,0] forState: UIControlStateHighlighted];     [BtnRefresh setBackgroundImage: [[UIImage imageNamed: @ "ggrey1.png"] stretchableImageWithLeftCapWidth: 12,0 topCapHeight: 0,0] forState: UIControlStateSelected];     [BtnRefresh addTarget: acción de auto: @selector (:) forControlEvents KeyboardRefresh: UIControlEventTouchUpInside];
    [BtnRefresh setUserInteractionEnabled: YES];     [BtnRefresh setMultipleTouchEnabled: YES];

[BottomView addSubview:btnRefresh];

si (self.isPortrait) {

    [btnRefresh setFrame:CGRectMake(71, 0, 40, 6)];

    [BottomView setFrame:CGRectMake(0, 160, 320, 41)];
}
else{

    [btnRefresh setFrame:CGRectMake(94, 0, 61, 8)];

    [BottomView setFrame:CGRectMake(0, 123, 480, 41)];
}

}

methos los anteriores está llamando y el

- (void) touchesBegan: (NSSet *) toca withEvent: (UIEvent *) evento

{ NSLog (@ "sí"); }

No está llamando cuando hago clic en butotn actualización.

puede alguien que me ayude. Gracias de antemano

¿Fue útil?

Solución

Usted no tiene la @selector para touchesBegan. En su lugar, tiene por KeyboardRefresh. No comprueba si el botón pressage en touchesBegan. En lugar reemplaza su touchesBegan con:

-(void)KeyboardRefresh:(id) sender
{ 
    NSLog(@"yes");
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top