一键式隐藏按钮 [英] Hide button on one touch itself

查看:48
本文介绍了一键式隐藏按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一键隐藏按钮.当用户触摸该按钮时,该按钮应该隐藏起来,但是一按即可.这些按钮是随机移动的.移动的按钮应隐藏起来.我已经做到了,但是在按下两次三下后,它就会隐藏起来.我正在使用touchupinside事件.谁能帮我吗?

i want to hide button on one touch itself. when the user touches the button that button should get hide but on one touch.The buttons are moving randomly. The moving buttons shoul get hide on touch. i have done it but after two three times pressing only it gets hide. i am using touchupinside event. Can anyone help me?

-(IBAction)clickButton1:(id)sender
{
    if (button1.tag==1)
    {
        button1.hidden=TRUE;
    }
    else
    {
        button1.hidden=FALSE;
    }
}
-(IBAction)clickButton2:(id)sender
{
    if(button1.hidden==TRUE && button3.hidden==FALSE) 
    {
        button2.hidden=TRUE;
    }
    else
    {
        button2.hidden=FALSE;
    }
}

预先感谢

推荐答案

使用此按钮touchUpInside替换代码

Replace your code with this Button touchUpInside

-(IBAction)hide:(id)sender
{
    UIButton *tmp = (UIButton *)sender;
    tmp.hidden = YES;
}

这篇关于一键式隐藏按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆