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)ButtonRel开发者_如何转开发eased:(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.
[button addTarget:self action:@selector(ButtonReleased:) forControlEvents:UIControlEventTouchUpInside];
精彩评论