这是我的问题.
我使用块一个接一个地在屏幕上显示两个标签(出现一个READY标签,然后消失,GO!标签出现,然后消失).
我还有一个手势识别器来检测用户是否正在拖动视图.
当我的应用程序显示标签时,手势识别器会停止调用其回调.
这是我的代码:
[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];
}];
}];
Run Code Online (Sandbox Code Playgroud)
到目前为止我尝试使用NSThread在主线程之外执行我的块,但没有结果.
我可以performSelector:withObject:afterDelay用来避免我的标签问题(在第一个动画完成后显示一个标签),但我认为它有点脏.
为什么我的手势识别器会停止调用他的回调?块是否对此负责?
iphone objective-c uigesturerecognizer ios objective-c-blocks