有两个按钮,这意味着有2个动作。如何隐藏第二个按钮并仅在按下第一个按钮后显示它?
代码:
- (IBAction)btnFirst:(id)sender {
//this button should reveal the button bellow called btnSecond
}
else{
}
}
}
- (IBAction)btnSecond:(id)sender {
}
else{
}
}
@property (strong, nonatomic) IBOutlet UIButton *boxOne;
@property (strong, nonatomic) IBOutlet UIButton *boxTwo;
答案 0 :(得分:2)
在你的'viewDidLoad` ....
中self.boxTwo.hidden = YES;
然后在IBAction
- (IBAction)btnFirst:(id)sender {
self.boxTwo.hidden = NO;
}
答案 1 :(得分:0)
请确保在您的视图中,boxOne位于boxTwo之上,然后您可以使用:
- (IBAction)btnFirst:(id)sender {
self.boxOne.hidden = YES;
}
答案 2 :(得分:0)
使用隐藏属性隐藏按钮。使用boxTwo.hidden = YES;在第二个按钮操作方法
- (IBAction)btnFirst:(id)sender {
self.boxTwo.hidden = NO;
}
答案 3 :(得分:0)
在情节提要中,选择boxTwo
按钮,然后转到右侧窗格中的属性检查器(中间的那个),然后在view
类别中,选中hidden
的复选框检查。然后这样做:
- (IBAction)btnFirst:(id)sender {
self.boxTwo.hidden = NO;
}