我做了什么…
只需在故事板中的视图中添加一个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文件,你会发现它们不是.如果您转到故事板并单击视图控制器,请查看插座下方,您将看到“已接收 *** 作”的选项卡.将控件连接到那里的 *** 作,它们将再次工作. 总结以上是内存溢出为你收集整理的ios – 在Xcode更新到4.5版之后Button不起作用全部内容,希望文章能够帮你解决ios – 在Xcode更新到4.5版之后Button不起作用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)