ios按钮中代添加按钮事件的代码写法

2020-12-21 06:27:34

创建按钮时添加如下代码:

UIButton* btn = [[UIButton alloc] init];/* btn 的其他设置 *///[btn addTarget:self action:@selector(doSth:) forControlEvents:UIControlEventTouchUpInside];[view addSubview:btn];

并添加响应函数的实现如下:

-(void)doSth:(UIButton*)sender{NSLog(@"click do Sth");}


  • 2019-09-29 10:28:04

    程序员实用工具网站

    程序员开发需要具备良好的信息检索能力,为了备忘(收藏夹真是满了),将开发过程中常用的网站进行整理。