If you are not using IBOutlet
then you can add button using code.
UIButton *btnDisplay = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
[btnDisplay setTitle:@"display" forState:UIControlStateNormal];
[btnDisplay addTarget:self action:@selector(DisplayMessage:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btnDisplay];
If you use IBOutlet
then you have to add below code in viewDidLoad
or any other as per your requirement
[btnDisplay addTarget:self action:@selector(DisplayMessage:) forControlEvents:UIControlEventTouchUpInside];
and implement this method.
-(void)DisplayMessage:(id)sender
{
//do what you want
}
Maybe this will help you.