Domanda

In my iOS app I'm trying to perform following simple animation:

- (void)dismissToolbar
{


    NSLog(@"bx: %f by: %f bw: %f bh: %f ",
            toolbar.frame.origin.x,
            toolbar.frame.origin.y,
            toolbar.frame.size.width,
            toolbar.frame.size.height);

    CGRect tempRect = CGRectMake(0,
                                 toolbar.frame.origin.y + toolbar.frame.size.height,
                                 toolbar.frame.size.width,
                                 toolbar.frame.size.height);

    [UIView animateWithDuration:animationsDuration
                          delay:0
                        options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowAnimatedContent
                     animations:^{
                         NSLog(@"bx: %f by: %f bw: %f bh: %f ",
                               tempRect.origin.x,
                               tempRect.origin.y,
                               tempRect.size.width,
                               tempRect.size.height);
                         toolbar.frame = tempRect;   // frame value doesn't change here!
                     }
                     completion:^(BOOL finished) {

                         NSLog(@"bx: %f by: %f bw: %f bh: %f ",
                               toolbar.frame.origin.x,
                               toolbar.frame.origin.y,
                               toolbar.frame.size.width,
                               toolbar.frame.size.height);
                         NSLog(@"dismiss toolbar complete");
                         [toolbar setHidden:YES];
                         isPlayerToolbarActive = NO;
                         isDissmissingToolbar = NO;
                     }
     ];

    [[NSNotificationCenter defaultCenter] postNotificationName:@"animateSidePanels" object:@"removingPlayerToolbar"];
}

I'm getting the following output to a console from the logs above:

bx: 0.000000 by: 724.000000 bw: 1024.000000 bh: 44.000000

bx: 0.000000 by: 768.000000 bw: 1024.000000 bh: 44.000000

bx: 0.000000 by: 724.000000 bw: 1024.000000 bh: 44.000000

dismiss toolbar complete

as you can see the value of the frame didn't change...and I don't really understand why...

any kind of help is highly appreciated!

È stato utile?

Soluzione

Did you create the view with xib's or interfaceBuilder?

If so, try selecting the xib and deselecting use autoLayout

enter image description here

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top