2013-10-10 41 views
0

我有一種方法來動畫和重置下面給出的視圖。UIView動畫在IOS 7中不能正常工作

-(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]; 
    } 

} 

當我在這個方法中傳遞YES和一個標記時,它會動畫到頂部,當我傳遞NO時,它將重置視圖。 它完美IOS6中。當我更新到IOS 7,重置完成爲:enter image description here

它不會動畫completeley和黑色空間出現在底部。你能幫我解決這個問題嗎?

回答

0

我猜這是一個UITableView裏面?

如果是這樣,你不應該動畫它的框架,你應該使用:

– scrollToRowAtIndexPath:atScrollPosition:animated: 

或:

– scrollToNearestSelectedRowAtScrollPosition:animated: