简体   繁体   中英

UIView Animation not working properly in IOS 7

I have a method to animate and reset the view which is given below.

-(void)animateToFocus:(BOOL)animate index:(NSInteger)index {
    if (animate) {
        [UIView beginAnimations:@"Scroll" context:nil];
        [UIView setAnimationDuration:0.5];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationsEnabled:YES];
        self.view.frame = CGRectMake(0, -50*index, self.view.bounds.size.width, self.view.bounds.size.height);
        [UIView commitAnimations];

    } else {
        [UIView beginAnimations:@"Scroll" context:nil];
        [UIView setAnimationDuration:0.5];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationsEnabled:YES];
        self.view.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
        [UIView commitAnimations];
    }

}

When I pass YES and a tag in this method, it will animate to top and when I pass NO it will reset the view. It works perfectly in IOS6.When i update to IOS 7, resetting done as: 在此处输入图片说明

It will not animate completeley and a black space appear in the bottom. Can u please help me to solve this?

I'm guessing that's a UITableView inside?

If so, you shouldn't be animating it's frame you should use:

– scrollToRowAtIndexPath:atScrollPosition:animated:

or:

– scrollToNearestSelectedRowAtScrollPosition:animated:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM