A seemingly very basic problem, but it's frustrating me to no end and stalling progress. When I click and drag from a UIButton
or UIStepper
onto the View Controller, the option to add IBAction
connections aren't listed.
The View Controller is called BuyNowVC
and in my BuyNowVC.h
I have:
@interface BuyNowVC : UIViewController {
IBOutlet UIButton *buyButton;
IBOutlet UIStepper *myStepper;
}
@property (nonatomic, retain) IBOutlet UIButton *buyButton;
@property (nonatomic, retain) IBOutlet UIStepper *myStepper;
- (IBAction)buttonPressed;
- (IBAction)stepperPressed;
And in BuyNowVC.m
:
@synthesize buyButton;
@synthesize myStepper;
- (IBAction)buttonPressed {
NSLog(@"Button pressed!");
}
- (IBAction)stepperPressed {
NSLog(@"Stepper pressed!");
}
I'm definitely ctrl dragging onto the View Controller itself but the only options I get with both UIButton
and UIStepper
are Action Segue: push, modal, custom. No sign of buttonPressed
or stepperPressed
.
Edit
I should also mention that this isn't the root VC and the UIButton
is currently tied to a Segue to the next View Controller (so I can navigate my mockup) but it doesn't seem to make a difference if I remove it.
First, should BuyNow.m
be BuyNowVC.m
?
Second, if you are trying to tie an UIButton
to an IBAction
within your view controller and if that doesn't work, you might have missed re-naming the "Custom Class" field with the name of the view controller you try to connect the UIButton
to in storyboard.
Third, you mentioned ".... are Action Segue: push
, modal
, custom
. No sign of buttonPressed
or stepperPressed
.". This information tells me that you are trying to control drag your UIButton
onto another view controller, onto which you try to tie the IBAction
there - that is not possible.
Adding Screenshot:
Please check here in storyboard:
You have changed the "Custom Class" name for the UIButton
to your own button name.
Please change it back to UIButton
as name for "Custom Class" Field.
See ScreenShot:
Don't do this like in the image. Change it back to UIButton
. Once you have done so, you will see "Action Connection" waving "Hi" at you again upon control-Dragging to it.
Steps:
1.) Click on your UIButton
on your view controller in storyboard.
2.) Check the right-hand side panel (3rd tab from left) and change the "Custom Class" Field back to UIButton
.
So it should be: