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");}


  • 2018-01-01 10:50:49

    仿QQ长按弹出功能菜单

    android app普遍常用的弹出上下文菜单是列表式的。QQ列表,在上方弹出冒泡效果菜单,如图