I'm trying to create a UIButton programmatically. I have a button called "addCash" (which was already created in interface builder), upon tapping this button I want another button to dynamically appear. This button works fine when done in viewDidLoad, but this is not what I want as "addCash" needs to be tapped before this new button is to be created. This is what I have so far...
-(IBAction) addCash{
UIButton *theButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
theButton.frame = CGRectMake(80, 50, 150, 40);
[theButton setTitle:@"title" forState:UIControlStateNormal];
[theButton addTarget:self action:@selector(test:) forControlEvents:UIControlEventTouchUpInside];
[theButton setBackgroundImage:[UIImage imageNamed:@"edit.jpg"] forState:UIControlStateNormal];
[self.view addSubview:theButton];
}
hidden = YES
, and just unhide it when your first button is pressed? – yujitheButton
. Why are you retaining it? – eric.mitchellsender
is not required and if you don't use the value then why bother... – Paul.s