简体   繁体   English

单击UIView中的按钮后,使UIButton从UIViewController中消失

[英]Make UIButton disappear from UIViewController once a button in UIView is clicked

I have a UIViewController (JDTHViewController) with a UIView (JDTHMainMenu) In the view controller are two buttons that each, once clicked, move to two other separate view controllers. 我有一个带有UIView(JDTHMainMenu)的UIViewController(JDTHViewController)在视图控制器中有两个按钮,每个按钮一旦单击,便移至其他两个单独的视图控制器。 In the UIView are two other buttons (options and stats) that, once clicked, create subviews on top of the view, minus a few pixels from each side, and therefore hide the two buttons so you can interact with the subviews. 在UIView中,还有两个其他按钮(选项和统计信息),一旦单击它们,便会在视图顶部创建子视图,每侧减去几个像素,因此隐藏了这两个按钮,以便您可以与子视图进行交互。 Now when I run the simulator all my buttons are in the right positions but once one of the UIViews buttons are clicked they disappear and the segue buttons (ViewController switch buttons) are on top of my subviews. 现在,当我运行模拟器时,所有按钮都位于正确的位置,但是一旦单击UIViews按钮之一,它们就会消失,并且segue按钮(ViewController开关按钮)位于子视图的顶部。 I need these to disappear once 'options' or 'stats' is clicked. 单击“选项”或“统计”后,我需要将它们消失。 Is there a way to do this? 有没有办法做到这一点? I hope that made sense if not i'll post more info or code. 我希望这是有意义的,否则我会发布更多信息或代码。 Thanks! 谢谢!

yourButton.hidden=1; or [yourButton setHidden:1]; [yourButton setHidden:1];
Instead of 1 you can use YES . 可以使用YES代替1
Do you mean this? 你是这个意思吗

Create a delegate callback from the UIView to the viewController and hide it. 创建从UIView到viewController的委托回调,并将其隐藏。 If you want to hide two buttons at the same time sending a notification would be easier. 如果您想同时隐藏两个按钮,则发送通知会更容易。

Do you mean 你的意思是

buttonName.hidden = YES;

As you are in another class, hide it using NSNotificationCenter 当您在另一个班级中时,请使用NSNotificationCenter将其隐藏

Here is good example 这是一个很好的例子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM