我更新了我的
Xcode,突然所有在故事板中连接到选择器的按钮都不再起作用了.所有以编程方式编码的按钮和手势识别器都可以工作.部分地,他们称同样的IBActions.
我做了什么…
只需在故事板中的视图中添加一个Button和一个Label.在View Controller .h中,我向Label添加了一个Outlet并声明了IBAction.
文件:
.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
只是按钮不起作用.
StoryBoard:@L_502_1@