2012-03-06 22 views
0

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

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

回答

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. 
+0

我试过使用touchupoutside但图像不回隐藏状态。该图像列在我的viewcontroller.h ..我设法取消隐藏它,但未能隐藏回 – user870565 2012-03-06 23:05:01

1

尝试 UIControlEventTouchUpInside

编辑: 要看看你能到什么样的反应控制状态,见here。 这是如何控制按钮图像取决于状态:

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

这样的按钮将用户后恢复到正常状态将手指。这与IBActions没有任何关系。

+0

这是一个使用。 – 2012-03-06 10:59:35

+0

我已经使用TouchUpInside来激活按钮应该做的事情。当按钮仍然被按下时,高亮显示的按钮(我的图像)会显示。文发布这个突出显示的图像应该隐藏。这是我未能做到的效果(隐藏图像) – user870565 2012-03-06 23:08:44

+0

好吧,现在我想我知道你的意思了。看到我的更新答案。但是,我现在仍然明白'我正在使用'触摸'来检测触摸'的含义。如果这仍然不能回答你的问题,请添加一些代码。 – lawicko 2012-03-07 11:14:19

相关问题