Q:

Button click not registering

I have an Xcode 5 button problem. 
I create a number of button programatically on a UIViewController and then want to register clicks on these buttons. I use NSLog to track the clicks but it seems that no clicks are registered in the log. 
Can anyone help please?
The ultimate aim to to segue to next UIViewController on each button click, but was just testing to see if button clicks were registered first.
Here is how I create the buttons in viewDidLoad (only 1 shown).
NOTE: the if-statement used only to check which buttons were pressed in previous view.
- (void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view.

    NSString *myString = [NSString stringWithFormat:@"%d", self.tagNumber ];

    if (self.tagNumber == 1)
    {
        hotelButton = [UIButton buttonWithType:UIButtonTypeCustom];
        hotelButton.tag = 1;
        hotelButton.frame = CGRectMake(60, 60, 300.f, 100.f);

        UIImage *buttonImage1 = [UIImage imageNamed:@"buttonImage1.png"];
        [hotelButton setBackgroundImage:buttonImage1 forState:UIControlStateNormal];
        [self.view addSubview:hotelButton];

        // Add targets and actions
        [hotelButton addTarget:self action:@selector(buttonClicked) forControlEvents:UIControlEventTouchUpOutside];
    }

}
And here is how I check for button clicks
- (void) buttonClicked
{
    NSLog(@"Button %i clicked", hotelButton.tag);
}

NOTE: I also tried the following:
- (void) buttonClicked:(UIButton *) button
{
    NSLog(@"Button %ld clicked", (long int)[button tag]);
}

But that gave an error "undeclared selector buttonClicked" in my viewDidLoad pointing to action@selector):
[hotelButton addTarget:self action:@selector(buttonClicked) forControlEvents:UIControlEventTouchUpOutside];

A:

Use this:
[hotelButton addTarget:self action:@selector(buttonClicked) 
    forControlEvents:UIControlEventTouchUpInside];

From Apple Docs:
UIControlEventTouchUpInside
A touch-up event in the control where the finger is inside the bounds of the control.

UIControlEventTouchUpOutside
A touch-up event in the control where the finger is outside the bounds of the control

And keep this method:
- (void) buttonClicked
{
    NSLog(@"Button %i clicked", hotelButton.tag);
}

