Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode hiding buttons

Tags:

button

ios

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?

like image 279
Curtis Boylan Avatar asked Jun 02 '13 21:06

Curtis Boylan


2 Answers

In code

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

Interface Builder

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...

enter image description here

like image 168
Daniel Avatar answered Oct 18 '22 20:10

Daniel


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
like image 40
terry Avatar answered Oct 18 '22 19:10

terry