如何隐藏objective-c中的按钮

时间:2014-08-18 17:08:28

标签: objective-c cocoa-touch

所以,我意识到有多个线程在询问这类问题,但它们都没有真正描述我遇到的那种错误。

我在这里创建我的变量并设置我的方法:

IBOutlet UIButton *BuildNewTower;
IBOutlet UIButton *CancelTower;

-(IBAction)BuildNewTower:(id)sender;
-(IBAction)CancelTower:(id)sender;

然后我在主类中调用这些函数,如下所示:

-(IBAction)BuildNewTower:(id)sender{
if(credits >= 15){
    BuildNewTower.hidden = YES;
    CancelTower.hidden = NO;

    Tower1S.hidden = NO;
    Tower2S.hidden = NO;
    Tower3S.hidden = NO;
    Tower4S.hidden = NO;
    Tower5S.hidden = NO;
    }
}

-(IBAction)CancelTower:(id)sender{
BuildNewTower.hidden = NO;
CancelTower.hidden = YES;

Tower1S.hidden = YES;
Tower2S.hidden = YES;
Tower3S.hidden = YES;
Tower4S.hidden = YES;
Tower5S.hidden = YES;
}

粗略地总结一下,BuildNewTower和CancelTower按钮不会对它们继承的.hidden变量做出反应。所有其他对象(所有ImageViews)确实会消失。

我猜这可能与按钮有关,而且它们被隐藏了?

0 个答案:

没有答案