iphone - 如何使手势识别器在动画 UIImage View 中工作

标签 iphone ios uigesturerecognizer uianimation

我在 ImageView 中有 5 个动画图像,并希望允许用户根据默认 ID 点击它们并将其推送到另一个 View 。我尝试添加手势点击,但 ImageView 未检测到。

有人可以给我一些建议吗?

编辑:最后我没有使用它,而是设置了一个 UIButton。

谢谢你:)

viewDidLoad

self.defaultID = [[NSMutableArray alloc] initWithObjects:@"7",@"9",@"11",@"27",@"6",nil];
self.defaultImageCaption = [[NSMutableArray alloc] initWithObjects:@"Ver",@"Green",@"Red",@"CF",@"Dwarf",nil];

//default image
imageViewTop.alpha = 1.0;
imageViewBottom.alpha = 0.0;
imageViewBottom = [[UIImageView alloc] initWithFrame:CGRectMake(0,44,320,367)];
imageViewTop = [[UIImageView alloc] initWithFrame:CGRectMake(0,44,320,367)];

singleDefaultTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleDefaultTap:)];
singleDefaultTap.numberOfTouchesRequired = 1;
imageViewTop.userInteractionEnabled = YES;
[imageViewTop addGestureRecognizer:singleDefaultTap];
imageViewTop.tag = 2000;

UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0,44,320,367)];
[topView addSubview:imageViewTop];
[self.view addSubview:imageViewTop];
[self.view addSubview:topView];
[self.view addSubview:imageViewBottom];

[self nextAnimation]

-(void)nextAnimation{

//picture loop
imageViewTop.image = imageViewBottom.image;
imageViewBottom.image = [imageArray objectAtIndex:[imageArray count] - 1];

[imageArray insertObject:imageViewBottom.image atIndex:0];
[imageArray removeLastObject];
imageViewTop.alpha = 1.0;
imageViewBottom.alpha = 0.0;

[UIView animateWithDuration:4.0
                 animations:^{ 
                     imageViewTop.alpha = 0.0;
                     imageViewBottom.alpha = 1.0;
                     } 
                 completion:^(BOOL  completed){
                     [self nextAnimation:stringsize.width];
                 }
 ]; 

Action

//显示你的警报...

NSLog(@"tapped");

flowerDetails = [[FlowerDetailViewController alloc] initWithNibName:@"FlowerDetailViewController" bundle:Nil] ;
Fr *fr = nil;

//推送到花朵详情 View

最佳答案

我会在 ImageView 之上添加一个透明 View ,并向其添加一个手势识别器。

关于iphone - 如何使手势识别器在动画 UIImage View 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8340329/

相关文章:

ios - 将数据附加到帖子正文并上传到 api

iOS swift : UIPanGestureRecognizer on 2 differents views

iphone - 长按每次轻按会掉落 2 个引脚

ios - UIScrollView 在进入 UIPageViewController 时不滚动

ios - swift 陀螺偏航、俯仰、横滚

iphone - iPhone 上的核心数据中的字符串被截断

javascript - 如何修复 jQuery Mobile 的固定页脚?

iphone - 在 iPhone 上使用 AMF 而不是 JSON? (对于网络服务)

ios - 视觉节点之间的视觉寻路

ios - Mapbox iOS - 显示多个标注