I added a new 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];
and I see it on the screen, but it does not respond to the gesture of pressing. It should call "buttonPressed". Any help would be super!
source share