猿问

在ViewDidLoad 里添加UIButton的点击事件,不能触发。

UIButton*btn2=[[UIButtonalloc]initWithFrame:CGRectMake(0,38,100,38)];
[btn2setTitle:@"添加好友"forState:UIControlStateNormal];btn2.titleLabel.font=[UIFontsystemFontOfSize:16];
[btn2addTarget:selfaction:@selector(btn2Click:)forControlEvents:UIControlEventTouchDown];
之前可以触发,现在不知是何原因不能触发了?
拉莫斯之舞
浏览 252回答 2
2回答

墨色风雨

改成如下代码再试试UIButton*btn2=[[UIButtonalloc]initWithFrame:CGRectMake(0,38,100,38)];[btn2setTitle:@"添加好友"forState:UIControlStateNormal];btn2.titleLabel.font=[UIFontsystemFontOfSize:16];[btn2addTarget:selfaction:@selector(btn2Click:)forControlEvents:UIControlEventTouchUpInside];
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答