Skip to content

有的button不能添加点击事件? #2

@lyuxxx

Description

@lyuxxx
UIButton *btn1 = [UIButton buttonWithType: UIButtonTypeCustom];
    [btn1 setImage: [UIImage imageNamed: @"cart"] forState: UIControlStateNormal];
	[btn1 addTarget:self action:@selector(log) forControlEvents:UIControlEventTouchUpInside];

    UIButton *btn2 = [UIButton buttonWithType: UIButtonTypeCustom];
    [btn2 setImage: [UIImage imageNamed: @"setting"] forState: UIControlStateNormal];
	[btn2 addTarget:self action:@selector(log) forControlEvents:UIControlEventTouchUpInside];

    UIButton *btn3 = [UIButton buttonWithType: UIButtonTypeCustom];
    [btn3 setImage: [UIImage imageNamed: @"user"] forState: UIControlStateNormal];
	[btn3 addTarget:self action:@selector(log) forControlEvents:UIControlEventTouchUpInside];

demo里面的代码添加,只有btn1会响应事件

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions