4

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.stack.imgur.com/1hruM.png

Cœur
  • 37,241
  • 25
  • 195
  • 267
BJS
  • 71
  • 3
  • 7
  • 3
    Tried reconnecting the targets-actions in IB? It seems to me that the problem is regarding Interface Builder (another reason for making UI from code...) –  Sep 21 '12 at 10:55
  • 2
    After the error I made a new Project... same Problem – BJS Sep 21 '12 at 11:02

2 Answers2

3

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.

Justine
  • 381
  • 2
  • 8
  • How does one solve this problem when the IBActions are inherited as they are not shown in the .h directly? – Andrew S Oct 26 '12 at 10:22
1

I have been seeing the exact same issue for many of our apps. In all of my cases it was fixed by reconnecting the action in Interface Builder.

Anders
  • 319
  • 2
  • 6