UITapGestureRecognizer不起作用时,我UIImageViewanimation
当我想animation的UIImageView
, UITapGestureRecognizer
添加到它不能工作。 为什么???
-(void) testTap:(id)sender { NSLog(@"Test tap..."); } -(void) testSlide { UITapGestureRecognizer* testTap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(testTap:)] autorelease]; testTap.numberOfTapsRequired = 2; UIImageView* imageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tip_slide"]] autorelease]; [imageView setFrame:CGRectMake(40, 40, 200, 200)]; imageView.userInteractionEnabled = YES; imageView.multipleTouchEnabled = YES; [imageView addGestureRecognizer:testTap]; [self.view addSubview:imageView]; // When I add the following code, the UITapGestureRecognizer will not work. WHY??? imageView.alpha = 0; CGAffineTransform t = imageView.transform; if (CGAffineTransformIsIdentity(t)) { UIViewAnimationOptions options = UIViewAnimationCurveEaseInOut; [UIView animateWithDuration:1.0 delay:0 options:options animations:^{ imageView.alpha = 1.0; } completion:^(BOOL finished) { if (finished) { [UIView animateWithDuration:1.0 delay:2.0 options:options animations:^{ imageView.alpha = 0.4; } completion:^(BOOL finished) { if (finished) { [imageView removeFromSuperview]; } }]; } }]; } }
您需要在animation过程中允许用户进行交互。
UIViewAnimationOptions options = UIViewAnimationCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction;
只是为Swift添加这个…这样的东西将工作得很好…使用.AllowUserInteraction 。
UIView.animateWithDuration(0.4, delay: 1.5, usingSpringWithDamping: 0.5, initialSpringVelocity: 20, options: UIViewAnimationOptions.AllowUserInteraction, animations: {self.frame = originalFrame}, completion: nil)
- ios在对象处理的同时识别手势
- 谷歌地图(networking应用程序)如何在iphone / ipad上使用手势/缩放进行平滑缩放?
- 如何在视图animation时识别点按手势
- UINavigationController交互式stream行手势不工作?
- 如何实现在UITableView Cell中左右滑动,与iOS Mail类似
- 使用UIView同步animation键盘,同时在iOS7中向后滑动
- 获取手势以使用Subclassed UIButton
- UITablevlewCell中的UIImageView上的UITapGestureRecognizer没有被调用
- 滚动时,UIScrollView取消UIPageViewController手势