Ios tvOS:DidUpdateFocusInText阻止点击次数
我在视图中有几个自定义按钮,并使用Ios tvOS:DidUpdateFocusInText阻止点击次数,ios,objective-c,tvos,apple-tv,Ios,Objective C,Tvos,Apple Tv,我在视图中有几个自定义按钮,并使用didUpdateFocusInContext将它们制作成自定义焦点动画,并且我在视图中添加了一个UITapGestureRecognitizer,当用户点击两次时,将运行一个方法!但问题是,当didUpdateFocusInText阻止双击操作,直到聚焦上下文到达其末尾(这意味着直到最后一个按钮),那么方法将在没有聚焦上下文时触发!!!怎样才能防止这样的事情?这是我的密码: - (void)didUpdateFocusInContext:(UIFocusUpd
didUpdateFocusInContext
将它们制作成自定义焦点动画,并且我在视图中添加了一个UITapGestureRecognitizer
,当用户点击两次时,将运行一个方法!但问题是,当didUpdateFocusInText
阻止双击操作,直到聚焦上下文到达其末尾(这意味着直到最后一个按钮),那么方法将在没有聚焦上下文时触发!!!怎样才能防止这样的事情?这是我的密码:
- (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context withAnimationCoordinator: (UIFocusAnimationCoordinator *)coordinator {
//Setup focausing for main buttons
for (UIButton *mainButton in _nextPrevButton){
if (context.nextFocusedView == mainButton) {
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:.40 initialSpringVelocity:.60 options:UIViewAnimationOptionAllowUserInteraction animations:^ {
context.nextFocusedView.transform = CGAffineTransformMakeScale(1.2, 1.2);
context.nextFocusedView.layer.shadowOffset = CGSizeMake(0, 0);
context.nextFocusedView.layer.shadowOpacity = 1;
context.nextFocusedView.layer.shadowRadius = 15;
context.nextFocusedView.layer.shadowColor = [UIColor lightGrayColor].CGColor;
context.nextFocusedView.layer.shadowOpacity = 1;
} completion:nil];
} else {
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:.40 initialSpringVelocity:.60 options:UIViewAnimationOptionAllowUserInteraction animations:^ {
context.previouslyFocusedView.transform = CGAffineTransformMakeScale(1, 1);
context.previouslyFocusedView.layer.shadowOpacity = 0;
} completion:nil];
}
}
if (context.nextFocusedView == _button1Focused) { [self buttonFocused:context]; } else if (context.previouslyFocusedView == _button1Focused) { [self buttonNotFocused:context]; }
if (context.nextFocusedView == _button2Focused) { [self buttonFocused:context]; } else if (context.previouslyFocusedView == _button2Focused) { [self buttonNotFocused:context]; }
if (context.nextFocusedView == _button3Focused) { [self buttonFocused:context]; } else if (context.previouslyFocusedView == _button3Focused) { [self buttonNotFocused:context]; }
}
攻丝方法:
我试过其他国家:
if (sender.state == UIGestureRecognizerStateBegan)
{
// handling code
NSLog(@"UIGestureRecognizerStateBegan ");
}
if (sender.state == UIGestureRecognizerStateEnded)
{
// handling code
NSLog(@" UIGestureRecognizerStateEnded ");
}
if (sender.state == UIGestureRecognizerStateRecognized)
{
// handling code
NSLog(@"UIGestureRecognizerStateRecognized");
}
但是没有成功
if (sender.state == UIGestureRecognizerStateBegan)
{
// handling code
NSLog(@"UIGestureRecognizerStateBegan ");
}
if (sender.state == UIGestureRecognizerStateEnded)
{
// handling code
NSLog(@" UIGestureRecognizerStateEnded ");
}
if (sender.state == UIGestureRecognizerStateRecognized)
{
// handling code
NSLog(@"UIGestureRecognizerStateRecognized");
}