开发者

ObjC Button Released Touch Up Outside

I have a b开发者_JS百科utton, when held down motion occurs, when released it should stop. I know I could write two methods, one to start and one to stop motion, I was wondering if in the one method I could detect both based on Touch Up Outside vs. Touch Up Inside.

If Touch Up Outside do this if Inside do this.

-(IBAction) startMotion: (id)sender {
    NSLog(@"Forward or back button is being pressed.");
    UIButton * buttonName = (UIButton *) sender;
        NSLog(@"Button Name:  %@",  buttonName.currentTitle);
}


Yes, you could write one method and link the IBAction "touchUpInside" and "touchUpOutside" to the same IBAction member function - via Interface Builder.

The only downside would be that you would not be able to tell if it was a touchUp inside or outside when it was called. (It doesn't sound like this matters to you.)

If the later was an issue, you could alternately implement independent touchUpInside and touchUpOutside methods which in turn call the same method - a third custom one - into which you could pass an "inside" or "outside" flag from the proper IBAction handler.


Touch up Outside won't give you the functionality you're looking for, I don't think. The person would have to move their finger outside the boundaries of the button and then lift remove the finger Why not use touchdown to initiate the motion and touch up inside to stop it?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜