【发布时间】:2019-12-23 19:40:52
【问题描述】:
我有一个类似于 macOS 扩展坞的视图 - 它可以完全移出屏幕。
我的手势识别器看起来像:
-(void)swipeDown:(UISwipeGestureRecognizer *)sender
{
NSLog(@"Swipe Down");
// this should move the dock 10 pixels below the bottom of the screen
[UIView animateWithDuration:0.5
delay:0.0
options:UIViewAnimationOptionCurveEaseOut
animations:^{[self dockView].frame = CGRectMake(kSafeMarginHorizontal, self.view.frame.size.height + 10, self.view.frame.size.width - (kSafeMarginHorizontal * 2), 80);}
completion:nil];
}
我只在我的dockView 上使用了一个自动调整大小的蒙版,并固定了左右边缘。在我的主要父视图中,我调用:
[[self view] setTranslatesAutoresizingMaskIntoConstraints:YES];
这可以正常工作,但在滑出屏幕后,相应的向上滑动手势不再起作用,如果我再次向下滑动,我不再得到指示该方法被调用的 NSLog。
我可以通过不将视图完全滑出屏幕来防止这种情况。如果我在屏幕上留下至少几个像素,它会继续正常工作。
为什么这会破坏我的手势识别器?
【问题讨论】: