在Xcode中,IBAction负责检测按钮的释放

时间:2012-03-06 10:02:28

标签: xcode image uibutton uiimage ibaction

我为UIBUTTON设置了图像。单击此按钮时,将显示图像的突出显示版本。当用户释放按钮时,这个突出显示的图像应该回到隐藏状态,通过“BUTTON.hidden = YES”..问题是我不知道哪个IBAction监听释放按钮。我尝过其中一些但没有成功。

我正在使用“触摸”来检测触摸。

2 个答案:

答案 0 :(得分:1)

尝试UIControlEventTouchUpInside

修改 要查看您可以对哪些控制状态做出反应,请参阅here。 这是根据状态控制按钮图像的方法:

[myButton setImage:[UIImage imageNamed:@"button_state_normal"] forState:UIControlStateNormal];
[myButton setImage:[UIImage imageNamed:@"button_state_selected"] forState:UIControlStateSelected];

这样,用户移开手指后按钮将返回正常状态。这与IBActions没有任何关系。

答案 1 :(得分:0)

https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIControl_Class/Reference/Reference.html

来自我相信的文档

UIControlEventTouchUpOutside  is the event

<强> UIControlEventTouchUpOutside

A touch-up event in the control where the finger is outside the bounds of the control.
Available in iOS 2.0 and later.
Declared in UIControl.h.