ios 当另一个按钮被点击时隐藏 UIButton

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5830175/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 19:44:34  来源:igfitidea点击:

Hide a UIButton when another button is tapped

ioscocoa-touchuibuttonhide

提问by Christina

How can I hide a UIButtonon the tap of another button, or any other event?

如何UIButton在点击另一个按钮或任何其他事件时隐藏 a ?

回答by dks1725

Create an outlet for the button to hide and connect it in your xib:

为按钮创建一个出口,以在您的 xib 中隐藏和连接它:

IBOutlet UIButton *myButton;

Now create an IBActionfor the other button and connect it in the xib:

现在IBAction为另一个按钮创建一个并将其连接到 xib 中:

-(IBAction)hideButton
{
    myButton.hidden = YES;
}

So now when you click on the second button, it will hide myButton.

所以现在当你点击第二个按钮时,它会隐藏myButton.

回答by Gypsa

In your IBActionfor the button tap:

在您IBAction的按钮中点击:

 [*yourbutton* setHidden:YES];

回答by Mitesh Khatri

[self.btnReport setHidden:YES];

回答by Thomas Stone

-(IBAction)hideButton
{
       yourbutton.hidden = YES;
}

That should do it.

那应该这样做。

回答by Krishnabhadra

Do this in your other button's tap action:

在其他按钮的点击操作中执行此操作:

yourButton.hidden = YES;