抱歉标题不清楚。我希望能够将IBAction方法添加到我按以下方式添加的按钮中:
(。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];
}
}
问题是,如何将UIButton按钮操作(例如,TouchUpInside)连接到ButtonReleased方法。
答案 0 :(得分:5)
[button addTarget:self action:@selector(ButtonReleased:) forControlEvents:UIControlEventTouchUpInside];