Как я могу отключить нажатие кнопки, пока я показываю графику в течение 5 секунд? - PullRequest
1 голос
/ 06 ноября 2011

Как я могу отключить нажатие кнопки UIB ... пока я показываю графику в течение 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 ]

2 голосов
/ 06 ноября 2011

Вы можете использовать метод задержки:

//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 голос
/ 06 ноября 2011

// Под ред. Попробуйте вместо этого

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;
 }];
}];
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...