【发布时间】:2016-03-12 22:59:54
【问题描述】:
I added an image to a button. I am using gestures for animating the image in my sample app. It was working fine with iPhone 4, 4s, and 5 but the problem arise from iphone 5s.
` -(void)awakeFromNib
{
[super awakeFromNib];
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(characterImagedTapped)];
self.characterImageView.userInteractionEnabled = YES;
[self.characterImageView addGestureRecognizer:tapGestureRecognizer];
}
这里是characterImagedTapped函数,
' -(void) characterImagedTapped { if ([self.delegate respondsToSelector:@selector(didCharacterTapped:)]) [self.delegate performSelector:@selector(didCharacterTapped:)]; } ' 这个函数正在调用 didCharacterTapped。
When I tapped on the button it will call didCharacterTapped function it's implementation as below:
-(void)didCharacterTapped:(BOOL)tapped
{
if (tapped && !isCharacterAnimating) {
[self startWelcomeBackCharacterAnimation];
}
}`
如果点击值为 YES,它将调用 startWelcomeBackCharacterAnimation。如果为 NO,它将跳过并且图像不会被动画化。
实际上,当我点击按钮时,点击的布尔值应该是 YES,但从 iPhone 5s 版本开始,点击的布尔值总是显示 NO。
【问题讨论】:
-
-(void) characterImagedTapped { if ([self.delegate respondsToSelector:@selector(didCharacterTapped:)]) [self.delegate performSelector:@selector(didCharacterTapped:)]; } 这个函数正在调用 didCharacterTapped。
-
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(characterImagedTapped)];self.characterImageView.userInteractionEnabled = YES; [self.characterImageView addGestureRecognizer:tapGestureRecognizer]; } 这个函数调用 characterImagedTapped 函数
-
不要将代码放入 cmets。请根据需要更新您的问题。