Search code examples
iosxcodebuttonibactionxcode4.5

Button doesn't work after Xcode update to version 4.5


I have updated my Xcode and suddenly all Buttons, which are connected in the storyboard to the selectors, doesn't work anymore. All programmatically coded Buttons and gesture recognizers work. Partly, they are calling the same IBActions.

What have I done...

Just add a Button and a Label to the View in the Storyboard. In the View Controller .h I added a Outlet to the Label and declare the IBAction. The files:

.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UILabel *myLabel;

-(IBAction)button_pressed:(id)sender;
-(IBAction)swipe_active:(id)sender;

@end

.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize myLabel;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    UISwipeGestureRecognizer *swipe_left = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipe_active:)];
    swipe_left.direction = UISwipeGestureRecognizerDirectionLeft;
    [self.view addGestureRecognizer:swipe_left];
}

-(IBAction)button_pressed:(id)sender{
    myLabel.text=@"Button is Running";
}
-(IBAction)swipe_active:(id)sender{
    myLabel.text=@"Swipe is Running";
}

@end

And just the Button does not work.

StoryBoard: https://i.sstatic.net/1hruM.png


Solution

  • I had this same exact problem after upgrading to xcode 4.5. The IBActions appear as though they are set up correctly in IB but if you look at the .h and .m files, you'll see they're not. If you go to your storyboard and click on your view controller, look under the outlets and you'll see a tab for "Received Actions". Hook up your controls to your actions there and they'll work again.