ボタンをクリックしてサブビューを移動しようとしていますが、クラッシュして-[MainGameDisplay openTimeChanger:]: unrecognized selector sent to instance 0x10e443d0
これが私がやっていることです:
@interface:
UIImageView *changerBackground;
@implementation
timerView = [[UIView alloc] initWithFrame:CGRectMake(0, 278, 105, 27)];
[self.view addSubview:timerView];
changerBackground = [[UIImageView alloc] init];
[changerBackground setImage:[UIImage imageNamed:@"speedbackground.png"]];
changerBackground.frame = CGRectMake(-12 , 9, 105, 33);
[changerBackground setUserInteractionEnabled:YES];
[timerView addSubview:changerBackground];
UIButton *timerBackground = [UIButton buttonWithType:UIButtonTypeCustom];
[timerBackground setBackgroundImage:[UIImage imageNamed:@"Time Background.png"] forState:UIControlStateNormal];
[timerBackground setBackgroundImage:[UIImage imageNamed:@"Time Background.png"] forState:UIControlStateHighlighted];
[timerBackground addTarget:self action:@selector(openTimeChanger:) forControlEvents:UIControlEventTouchUpInside];
timerBackground.frame = CGRectMake(-2 , 15, 102, 27);
[timerView addSubview:timerBackground];
-(void)openTimeChanger {
[UIView animateWithDuration:0.2f
animations:^{
changerBackground.frame = CGRectMake(-12 , -16, 105, 33);
}
completion:Nil];
}
changerBackground には 3 つのサブビューがあることにも注意してください。