Button does not work after upgrading Xcode to version 4.5

I updated my Xcode, and suddenly all the buttons that are connected to the storyboard in the selectors no longer work. All software-coded buttons and gesture recognizers work. In part, they call the same IBActions.

What I've done...

Just add a button and a label to the view in the storyboard. In the .h view controller, I added output to the shortcut and declare an IBAction. 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 

wow

 #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"; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end 

And only the button does not work.

StoryBoard: http://i.stack.imgur.com/1hruM.png

+4
source share
2 answers

I had the exact same problem after upgrading to xcode 4.5. IBActions look like they are configured correctly in IB, but if you look at the .h and .m files, you will see that it is not. If you go into the storyboard and click on the controller of your kind, look under the exits and you will see the โ€œReceived Actionsโ€ tab. Connect your controls to your actions and they will work again.

+3
source

I saw the same problem for many of our applications. In all my cases, this has been fixed by reconnecting the action in Interface Builder.

+1
source

Source: https://habr.com/ru/post/1435480/


All Articles