tvOS Gesture Recognizer在滑出屏幕后停止工作

问题描述 投票:0回答:1

我有一个类似于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。

我可以通过不将视图完全滑出屏幕来防止这种情况。如果我在屏幕上至少留下了几个像素,它将继续正常工作。

为什么这会打断我的手势识别器?

uigesturerecognizer tvos
1个回答
0
投票

当焦点对准的按钮最终移出屏幕时,tvOS似乎不喜欢它。我还通过更改约束将其更改为动画。关键是在动画结束时调用setNeedsFocusUpdate

//  flush pending layout operations, then animate the constraint change
[[self view] layoutIfNeeded];
[UIView animateWithDuration:0.25
                      delay:0.0
                    options:UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionAllowUserInteraction
                 animations:^{[[self dockViewConstraint] setConstant:1080];
                              [[self view] layoutIfNeeded];}
                  completion:^(BOOL finished){
                              // Do some cleanup after animating.
                              [self setNeedsFocusUpdate];}];
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.