Reputation: 827
I'm curious to know is there a way to edit what happens at a app startup to hide buttons? I can hide them when the app is running but I want some buttons hidden when the app starts up and displayed later on after me touching one of my displayed buttons, is there a way to do this?
Upvotes: 8
Views: 21291
Reputation: 1589
You could initially set your buttons hidden via the Attribute Inspector
.
There's a check box down there View -> Drawing -> Hidden
to hide the button.
Then you coud to set your buttons visible in the touch action of another visible button like following:
#import "HBOSViewController.h"
@interface HBOSViewController ()
// your buttons outlets here
@property (weak, nonatomic) IBOutlet UIButton *topButton1;
@property (weak, nonatomic) IBOutlet UIButton *topButton;
@end
@implementation HBOSViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
// The action of the visible button to make your hidden button visible.
- (IBAction)showButton:(id)sender {
if (self.topButton) {
self.topButton.hidden=NO;
}
if (self.topButton1) {
self.topButton1.hidden=NO;
}
}
@end
Upvotes: 1
Reputation: 23359
UIView
has a hidden
property. You can toggle it to hide/show as you want in code, for example:
myView.hidden = YES; // YES/NO
You'll want to do this anywhere after -viewDidLoad
In the inspector, once you've selected the view you want to hide, you should see something like this (look in the View > Drawing options - at the bottom).
It's the hidden property you want to check here... You'll want to make an outlet to your code so you can unhide this later on...
Upvotes: 10
Reputation: 7463
I assume you mean on a view which you created using a XIB (Interface Builder) file. If that's the case, simply set the hidden flag on any buttons you want to be initially hidden.
Upvotes: 0