代码之家  ›  专栏  ›  技术社区  ›  vikingosegundo

将动画移动到iOS4块时出现问题

  •  1
  • vikingosegundo  · 技术社区  · 14 年前

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.75];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp 
                           forView:containerView 
                             cache:YES];
    [secondView removeFromSuperview];
    [containerView addSubview:keypadView];
    [UIView commitAnimations];
    

    现在我想为基于iOS4块的api重写这段代码,因为我想使用completion块。我写了这个:

    [UIView transitionWithView:containerView
                      duration:.75 
                       options:UIViewAnimationTransitionCurlUp
                    animations:^{
                        NSLog(@"Hey Ho");
                        [secondView removeFromSuperview];
                        [containerView addSubview:keypadView];
                    } 
                    completion:NULL];
    

    我的代码怎么了?

    completion: ^(BOOL completed){
        NSLog(@"completed %d", completed);
    }
    

    没有帮助,因为根据文档,NULL是一个可接受的值

    4 回复  |  直到 14 年前
        1
  •  2
  •   Tiago Alves    14 年前

    执行: options:UIViewAnimationOptionTransitionCurlUp options:UIViewAnimationTransitionCurlUp

        2
  •  2
  •   Gordon Hughes    14 年前

    UIView类引用中的示例 可以 可能是错误的-或者在 animations 阻止对象,但我唯一能让它工作的方法如下:

    [secondView removeFromSuperview];
    [containerView addSubview:keypadView];
    [UIView transitionWithView:containerView
                      duration:.75
                       options:UIViewAnimationOptionTransitionCurlUp
                    animations:^{}
                    completion:^(BOOL finished) {
                        NSLog(@"finished %d", finished);
                    }];
    
        3
  •  1
  •   jessecurry    14 年前

    你走了吗 [UIView beginAnimations:nil context:nil]; 在你的新街区上面?

        4
  •  1
  •   Jeff Kelley    14 年前

    NULL ? 试着放一个 NSLog 里面有陈述什么的。我不知道 无效的