2011-08-21 73 views
2

我有一個UIViewController應控制2周的UIImageViews淡入在沒有濫用[UIView animateWithDuration]的情況下觸發延遲後的方法?

我管理使用的UIView animateWithDuration方法即可製作動畫,這樣的:

[UIView animateWithDuration:1.5 
    animations:^{ 
     [mFrontpageTitle setAlpha:0]; 
     [mFrontpageTitle setAlpha:1]; 
    } 
    completion:^(BOOL finished){ 
     [self AnimatePause]; 
    }]; 

-(void)AnimatePause { 
[UIView animateWithDuration:5.0 
    animations:^{ 
     [mFrontpageTitle setAlpha:0.99]; 
     [mFrontpageTitle setAlpha:1]; 
    } 
    completion:^(BOOL finished){ 
     [self AnimateAuthor]; 
    }]; 

其中火災下一個動畫。現在,創建一個從.99到1.0的轉換並不是很乾淨。

是否有更好的方法通過定義持續時間來觸發塊或發送消息?

感謝

Zuppa

回答

3
NSTimeInterval delay = 1.5; //in seconds 
[self performSelector:@selector(myMethod) withObject:nil afterDelay:delay]; 
+0

謝謝。我已經看到了完全錯誤的方向。我會看到,如果這個崩潰,如果UIView在間隔完成之前被刪除.. :) – Zuppa

+0

如果我想調用一個方法,需要兩個參數?例如:' - (void)MoveSomethigFrom:(id)from To:(id)to;' – Frade

+0

或者將你的方法包裝在只需要一個參數的東西(例如帶有所有參數的字典)中,或者使用'dispatch_after '(例子見[這裏](http://stackoverflow.com/a/4139331/573626))。 – omz

相關問題