UITapGestureRecognizer莫名其妙地停止识别轻击手势

阿奇

简而言之UITapGestureRecognizer,我分配给UIImageView遗嘱的a将不可避免地,莫名其妙地停止使用它所针对的方法。

它甚至更陌生,因为有时仅一次轻击一次它就会停止识别手势,而有时则需要数十次轻击。但是,每次都会无休止地终止。

我尝试将点击手势设置为强烈关联的属性,但这没有任何效果。

我最近尝试过的(没有成功)是,在运行手势的选择器方法之后,我删除了该手势,然后重新分配并重新初始化了一个新的手势UITapGestureRecognizer,但没有任何效果。这使我相信问题出在那UIImageView而不是UITapGuestureRecognizer-但话虽如此,我也不知道。

但是,我正在UIImageView通过一些UIView动画,所以也许有一些事情要做?

另外,UIImageView启用了用户交互,而我从未禁用它。

有什么建议么?如果可以的话,我很乐意发布代码。这是一些代码:

设置UIImageView(图像视图和轻击手势均已设置为属性,以便我可以将它们牢固地关联起来):

self.cardImageView = [[UIImageView alloc] initWithFrame:frame];
[self.cardImageView setContentMode:UIViewContentModeScaleAspectFill];
[self.cardImageView setClipsToBounds:TRUE];
[self.cardImageView setBackgroundColor:[UIColor nearBlack]];
[self.cardImageView.layer setBorderColor:[[UIColor fiftyGray]CGColor]];
[self.cardImageView.layer setBorderWidth:1.0];
[self.cardImageView setUserInteractionEnabled:TRUE];

self.imageFullScreenTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView)];
[self.cardImageView addGestureRecognizer:self.imageFullScreenTap];

[view addSubview:self.cardImageView];

动画:

[UIView animateWithDuration:0.2 animations:^
     {
         [self.cardImageView setFrame:[self frameForImageView]];

         [page setAlpha:!fullscreenTemplate];
         [saveExitButton setAlpha:!fullscreenTemplate];
         [optionsButton setAlpha:!fullscreenTemplate];

         if(fullscreenTemplate)
         {
             [self.cardImageView.layer setBorderColor:[UIColor clearColor].CGColor];
             [self.view setBackgroundColor:[UIColor blackColor]];
         }
         else
         {
             [self.cardImageView.layer setBorderColor:[UIColor fiftyGray].CGColor];
             [self.view setBackgroundColor:[UIColor clearColor]];
         }
     }
     completion:^(BOOL finished)
     {
         [scroller setScrollEnabled:!fullscreenTemplate];

         if (self.imageFullScreenTap)
         {
             [self.cardImageView removeGestureRecognizer:self.imageFullScreenTap];
             self.imageFullScreenTap = nil;
         }

         self.imageFullScreenTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView)];
         [self.cardImageView addGestureRecognizer:self.imageFullScreenTap];
     }];
瓦里夫·阿坎德·里希
[UIView transitionWithView:self.cardImageView
                  duration:0.2f 
                   options:UIViewAnimationOptionAllowUserInteraction |
                        UIViewAnimationOptionLayoutSubviews
                animations:^(void) {
                    [self.cardImageView setFrame:[self frameForImageView]];
                    [page setAlpha:!fullscreenTemplate];
                    [saveExitButton setAlpha:!fullscreenTemplate];
                    [optionsButton setAlpha:!fullscreenTemplate];
                    if(fullscreenTemplate) {
                        [self.cardImageView.layer setBorderColor:[UIColor clearColor].CGColor];
                        [self.view setBackgroundColor:[UIColor blackColor]];
                    } else {
                        [self.cardImageView.layer setBorderColor:[UIColor fiftyGray].CGColor];
                        [self.view setBackgroundColor:[UIColor clearColor]];
                    }
                } completion:^(BOOL finished) {
                    [scroller setScrollEnabled:!fullscreenTemplate];
                }]; 

上面的代码已animateWithDuration:completion:transitionWithView:duration:options:animations:completion:方法更改方法。重要的关键词这里是UIViewAnimationOptionAllowUserInteraction这将在图像动画时允许userInteraction。

如果TapGesture在一段时间后仍然无法识别,请向我显示您的tapImageView方法代码

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

文本莫名其妙地忽略了其容器的边界

来自分类Dev

Rails路由助手在请求之前莫名其妙地使用了“后安装”

来自分类Dev

Rails路由助手莫名其妙地将“ postinstall”添加到请求中

来自分类Dev

自定义函数会莫名其妙地停止某些值的工作

来自分类Dev

C代码莫名其妙地跳过了行

来自分类Dev

pandas.merge莫名其妙地缓慢

来自分类Dev

OpenGL矩形莫名其妙地占据了整个窗口

来自分类Dev

C代码莫名其妙地跳过了行

来自分类Dev

Javac 在 Hudson 上莫名其妙地失败了

来自分类Dev

jQuery .empty() && .append() 莫名其妙地失败

来自分类Dev

PHP 变量莫名其妙地更新

来自分类Dev

isKindOfClass莫名其妙的身份问题

来自分类Dev

bash:莫名其妙的行为

来自分类Dev

UIImage将无法识别轻击手势

来自分类Dev

tar莫名其妙地试图打开一个不存在的目录

来自分类Dev

ComputeHash调用莫名其妙地有所不同

来自分类Dev

Rails / Ruby:TimeWithZone比较莫名其妙地失败了等效值

来自分类Dev

画布drawImage莫名其妙地偏移了1个像素

来自分类Dev

yarn / npm在摩卡和打字稿中莫名其妙地使用了过时的代码

来自分类Dev

应用于元组的map函数总是莫名其妙地评估为True

来自分类Dev

Grails发布莫名其妙地无法发布到Nexus

来自分类Dev

tar莫名其妙地试图打开一个不存在的目录

来自分类Dev

油煎面包块显示不正确-CroutonQueue莫名其妙地卡住了?

来自分类Dev

庞手势识别器停止

来自分类Dev

草绘为XCode图像大小?(莫名其妙)

来自分类Dev

数组和循环中输出的莫名其妙的变化

来自分类Dev

莫名其妙的行为国防部重写

来自分类Dev

WebClient.DownloadFile的莫名其妙的行为

来自分类Dev

Azure Functions中的莫名其妙的存储事务

Related 相关文章

热门标签

归档