3

Sorry for the unclear title. I want to be able to add IBAction methods to a button I added in the following way:

(.h class)

{
    UIButton *button;
}
-(IBAction)ButtonReleased:(id)sender

(.m class)

{
    -(IBAction)ButtonReleased:(id)sender
    {
        //Actions done by button pointer
    }

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        [PlayButton setFrame:CGRectMake(10, 10, 100, 50)];
        [PlayButton setTitle:@"PlayButton" forState:UIControlStateNormal];
        [self.view addSubview:PlayButton];
    }
}

The question is, how can I connect the UIButton button action (say, TouchUpInside) to the ButtonReleased method.

rdelfin
  • 819
  • 2
  • 13
  • 31

1 Answers1

5
[button addTarget:self action:@selector(ButtonReleased:) forControlEvents:UIControlEventTouchUpInside];
esqew
  • 42,425
  • 27
  • 92
  • 132