Pergunta

I need a UIButton to perform a specific action when the user touches inside the button, the without releasing the touch drag outside the button and then release the finger. I don't want the action to be performed if he touches inside the button and then drags out and without raising the finger goes back into the button again and then release finger (which would effectively become a touch up inside, which is also not the sender I am looking for). Is there any sender type to do the particular action in the specified condition? I hope the doubt is clear enough. Please mention if you have doubt regarding what I asked.

Foi útil?

Solução

Is UIControlEventTouchUpOutside not working for you?

[myButton addTarget:self action:@selector(action) forControlEvents:UIControlEventTouchUpOutside];

Outras dicas

you can do it as below

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
    UITouch *aTouch = [touches anyObject];
    CGPoint point = [aTouch locationInView:self.view];

}

here what you need to do is that compare point (CGPoint) with your button's area and act accordingly

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top