0

I've made a custom button programmatically in

- (void)viewDidLoad

However I need to call one of its methods in

-(void) viewDidAppear:(BOOL)animated

I need to call

[self.custom setHidden:YES]

Is the buttons scope only in viewDidLoad?

HalR
  • 11,411
  • 5
  • 48
  • 80

1 Answers1

0

Assuming you're working with ARC:

Define it as a property in your class:

@property (nonantomic, strong) UIButton *myButton;

and assign it to that property in viewDidLoad:

UIButton *myBtn = [[UIButton alloc] init];
self.myButton = myBtn;
...
Stavash
  • 14,244
  • 5
  • 52
  • 80
  • You shouldnt use init on buttons. Either use UIControl or a button with type "custom". – Sulthan Jun 02 '13 at 22:39
  • This was only to represent the line of instantiation (better to call initWithFrame for instance or the convenience method of buttonWithType). Not sure why you suggest an alternative of UIControl but OK. – Stavash Jun 03 '13 at 06:20