2011-11-06 49 views
1

如何禁用從被壓一個UIButton ... 而我顯示5秒的圖形?如何在5秒內顯示圖形時禁用按鈕?

self.view.userInteractionEnabled = NO; // if you need the whole view disabled 
    //self.btn.enabled = NO; //if you need button only disabled 

    [UIView animateWithDuration:3.0f animations:^ 
     { 
      // your graphical changes 
      [(UILabel*)addLbl[1] setBackgroundColor:[UIColor redColor]]; 
     } 
    completion:^ (BOOL finished) 
     { 

      self.view.userInteractionEnabled = YES; 
      //self.button.enabled = YES; 
      [(UILabel*)addLbl[1] setBackgroundColor:[UIColor whiteColor]]; 
     } 
    ]; 

回答

2

可以使用延時方法:

//make your animations and graphical changes.. 
//.... 

self.myButton.enabled = NO; 
[self performSelector:@selector(changeButton) withObject:nil afterDelay:5.0]; //this will happen after 5 seconds 

-(void)changeButton { 
self.myButton.enabled = YES; 
} 
1

// EDITED。試試這個

self.view.userInteractionEnabled = NO; // if you need the whole view disabled 

[UIView animateWithDuration:3.0f animations:^ { 
    [(UILabel*)addLbl[1] setBackgroundColor:[UIColor redColor]]; 
} completion:^ (BOOL finished) { 
[UIView animateWithDuration:2.0f animations:^ { 
    [(UILabel*)addLbl[1] setBackgroundColor:[UIColor whiteColor]]; 
} completion:^ (BOOL hasFinished) { 
    self.view.userInteractionEnabled = YES; 
}]; 
}]; 
+0

的代碼段後,我把另一個圖形,但是,執行將不會顯示臨時圖形,當我把在該代碼段 – jdl

+0

如果您需要在一行幾動畫序列,像頭後其他圖形:門打開;第二:一個男人走過門 - 然後嘗試把你的其他動畫放在第一個動畫的完成塊內。讓我知道,如果這聽起來很清楚。 – Eugene

+0

我這樣做,並且該塊之後......結果是,臨時圖形從未顯示 – jdl

相關問題