简体   繁体   English

UIView动画在IOS 7中无法正常工作

[英]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. 当我通过YES和此方法中的标记时,它将动画到顶部,而当我通过否时,它将重置视图。 It works perfectly in IOS6.When i update to IOS 7, resetting done as: 它在IOS6中完美运行。当我更新到IOS 7,重置完成为: 在此处输入图片说明

It will not animate completeley and a black space appear in the bottom. 它将不会为completeley设置动画,并且底部会出现一个空白区域。 Can u please help me to solve this? 你能帮我解决这个问题吗?

I'm guessing that's a UITableView inside? 我猜里面是UITableView吗?

If so, you shouldn't be animating it's frame you should use: 如果是这样,则不应使用它的动画框架:

– scrollToRowAtIndexPath:atScrollPosition:animated:

or: 要么:

– scrollToNearestSelectedRowAtScrollPosition:animated:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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