0

尽管方法得到了完整的运行,但这里的动画永远不会被调用。

其他方法

 if (show) {
    [self dropTheHeader];
}

   -(void)dropTheHeader{


    NSLog(@"Show this damn method");

    [UIView animateWithDuration:2
                          delay:0
                        options:UIViewAnimationOptionCurveEaseOut
                     animations:^{
                         self.searchHeader.frame = CGRectOffset(self.searchHeader.frame, 0, -44);
                     }completion:^(BOOL finished){

                         self.searchHeader.hidden = YES;

                     }];
}

它太奇怪了。日志被调用,一切,只是没有动画。检查 self.searchHeader 是否为 Nil,没有骰子。有人有什么想法吗?

编辑

2013-09-26 11:34:47.362 Pict[3077:907] searchHeader hidden: no
2013-09-26 11:34:47.364 Pict[3077:907] the current frame is: {{0, 0}, {320, 88}}
2013-09-26 11:34:47.366 Pict[3077:907] the new frame is: {{0, -44}, {320, 88}}
2013-09-26 11:34:49.411 Pict[3077:907] the completed frame is: {{0, 0}, {320, 88}}
4

1 回答 1

1

试试这个,让我知道输出是什么:

[UIView animateWithDuration:2
                      delay:0
                    options:UIViewAnimationOptionCurveEaseOut
                 animations:^{
                     NSLog(@"searchHeader hidden: %@", self.searchHeader.hidden ? "yes" : "no");
                     NSLog(@"the current frame is: %@", NSStringFromCGRect(self.searchHeader.frame));
                     self.searchHeader.frame = CGRectOffset(self.searchHeader.frame, 0, -44);
                     NSLog(@"the new frame is: %@", NSStringFromCGRect(self.searchHeader.frame));
                 }completion:^(BOOL finished){

                     if (finished) {
                         NSLog(@"the completed frame is: %@", NSStringFromCGRect(self.searchHeader.frame));
                         self.searchHeader.hidden = YES;
                     } else {
                         NSLog(@"completion handler called before finishing animation");
                     }

                 }];
于 2013-09-26T18:19:14.687 回答