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];
}
}`
如果tapped值为YES,则会调用startWelcomeBackCharacterAnimation。如果它为NO,它将跳过并且图像不会被动画化。
实际上当我点击按钮时,点击的布尔值应为YES,但点击的bool值在iPhone 5s版本中始终显示NO。
答案 0 :(得分:1)
-(void) characterImagedTapped
{
if ([self.delegate respondsToSelector:@selector(didCharacterTapped:)]) {
[self.delegate performSelector:@selector(didCharacterTapped:) withObject:[NSNumber numberWithBool:YES]];
}
else {
[self.delegate performSelector:@selector(didCharacterTapped:) withObject:[NSNumber numberWithBool:NO]];
}
}
-(void)didCharacterTapped:(NSNumber *)tapped
{
if (tapped.boolValue) {
//[self startWelcomeBackCharacterAnimation];
}
else {
}
}
您可以使用对象执行选择器,并且您可以在选择器中按照上面的代码
访问对象值答案 1 :(得分:0)
形成您的评论我可以看到您将tapGestureRecognizer
设置为特定imageview
,即self.characterImageView
。
尝试将其分配给parentview
的{{1}}。
characterImageView