2014-01-29 56 views
2

我正在創建一個iOS應用程序,並且在一個方法中,我有一個for循環,它執行一系列動畫,並持續大約2秒。iOS直到動畫完成後才阻止旋轉

我的問題是,如果用戶旋轉設備,而動畫仍在進行中,它攪亂了格式化的新方向(一切正常,只是它應該如果旋轉發生的方式後的動畫完成)。

所以我想知道是否有延遲旋轉

+0

你使用'UIView'動畫塊嗎? – hgwhittle

+0

是的,我正在使用動畫塊 – user1855952

回答

0

你可以有你更新基於您的動畫是否完整或不BOOL實例變量的方式。然後覆蓋shouldAutorotate方法並返回BOOL。可能看起來像這樣:

@implementation YourViewController { 
    BOOL _shouldAutoRotate; 
} 

-(BOOL)shouldAutorotate { 
    [super shouldAutorotate]; 
    return _shouldAutoRotate; 
} 

-(void)yourAnimationMethod { 

    _shouldAutoRotate = NO; 

    [UIView animateWithDuration:2.0f animations:^{ 
     //your animations 
    } completion:^(BOOL finished) { 
     if(finished) { 
      _shouldAutoRotate = YES; 
     } 
    }]; 
}