ios – 在Xcode更新到4.5版之后Button不起作用
发布时间:2020-12-14 17:38:07 所属栏目:百科 来源:网络整理
导读:我更新了我的 Xcode,突然所有在故事板中连接到选择器的按钮都不再起作用了.所有以编程方式编码的按钮和手势识别器都可以工作.部分地,他们称同样的IBActions. 我做了什么… 只需在故事板中的视图中添加一个Button和一个Label.在View Controller .h中,我向Labe
我更新了我的
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:https://i.stack.imgur.com/1hruM.png 解决方法
升级到xcode 4.5后,我遇到了同样的问题. IBActions看起来好像在IB中设置正确,但是如果你看一下.h和.m文件,你会发现它们不是.如果您转到故事板并单击视图控制器,请查看插座下方,您将看到“已接收操作”的选项卡.将控件连接到那里的操作,它们将再次工作.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |