iphone - Objective-C block 停止 UIGestureRecognizer

标签 iphone objective-c ios uigesturerecognizer objective-c-blocks

这是我的问题。

我使用 block 在屏幕上一一显示两个标签(一个 READY 标 checkout 现,然后消失,GO!标 checkout 现,然后消失)。

我还有一个手势识别器来检测用户是否正在拖动 View 。

当我的应用程序显示标签时,手势识别器停止调用它们的回调。

这是我的代码:

[UIView animateWithDuration:1 animations:^{
    readyLabel.alpha = 0;
}completion:^(BOOL finished){
    [readyLabel removeFromSuperview];
    [self.view addSubview:goLabel];
    [UIView animateWithDuration:1 animations:^{
        goLabel.alpha = 0;
    }completion:^(BOOL finished){
        self.ball = [[Ball alloc] init];
        [self.view addSubview:self.ball];

        _timer = [NSTimer scheduledTimerWithTimeInterval:0.02 target:self selector:@selector(moveBall:) userInfo:nil repeats:YES];
    }];
}];

到目前为止,我尝试的是使用 NSThread 在主线程之外执行我的 block ,但没有结果。

我可以使用 performSelector:withObject:afterDelay避免我的标 checkout 现问题(在第一个动画完成后显示一个标签),但我认为它有点脏。

为什么我的手势识别器停止调用他的回调?区 block 是否对此负责?

最佳答案

这是因为 block 动画禁用了用户交互。您应该使用 animateWithDuration:delay:options:animations:completion:并指定 UIViewAnimationOptionAllowUserInteractionoptions .

关于iphone - Objective-C block 停止 UIGestureRecognizer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8266550/

相关文章:

ios - 发送带有特殊字符的 POST 请求 iOS

iPhone - 保存 URL 而不设置 URL :forKey: and NSURL

iphone - 如何制作一个应用程序的两个版本并让它们共享相同的设置?

ios - NSDateFormatter 提前一天

objective-c - 更改 Cocoa 中圆形按钮的大小

ios - UIView.transition 显示深色背景的父 View (Swift)

objective-c - NSMutableArray indexOfObject 返回一个非常大的数字

iOS - 基于设备的不同图像或缩放相同的图像?

ios - 在IOS7中打开应用程序时出现白屏

ios - UISearchBar subview 奇怪的行为