我添加了一个新的 UIButton
UIButton *newButton = [UIButton buttonWithType:UIButtonTypeCustom];
[newButton setFrame:CGRectMake(x, y, width, height)];
[newButton setTitle:@"" forState:UIControlStateNormal];
[newButton setTag:x+INDEX_OFFSET];
[newButton setBackgroundImage:image forState:UIControlStateNormal];
[newButton addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:newButton];
[self bringSubviewToFront:newButton];
我可以在屏幕上看到它,但它没有响应点击手势。它应该调用“buttonPressed”。任何帮助都会很棒!