I'm trying to use dynamic buttons created via code (no IB) in my project and they appear where and how I want them but they don't fire their actions.
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button1.frame = CGRectMake(475, 302, 49, 58);
[button1 setTitle:@"1"
forState:(UIControlState)UIControlStateNormal];
[button1 addTarget:self
action:@selector(goToFirstTrailer)
forControlEvents:(UIControlEvents)UIControlEventTouchDown];
[myImageView addSubview:button1];
-(void)goToFirstTrailer {
[self startAnimator:@"OutsideToTrailer1_" forNumFrames:60];
}
The imageView this is placed on has buttons and User Interaction Enabled On.
Any light you can shed would be much appreciated.
UIControlEventTouchUpInside
. – ClammycancelsTouchesInView
toNO
on the UISwipeGestureRecognizers. This is only supposed to prevent touch events when the gesture is successfully recognized so it shouldn't matter in this case, but it's worth trying. – Clammy