먼저 내 질문에 감사드립니다. 지금, 내 코드에서 어떤 함수를 호출하는 많은 다른 방법을 시도했지만 그것이 작동하는 방법 (performselector : withobject : afterdelay)은 함수에 즉시 들어가고 함수는 "if if"를 무작위로 만들 필요가있다. 타임스. 당신이 메신저 버튼을 누를 경우 확인하기 위해 노력하고 있지만이 immeditlly을 확인하고 지연 후에 그것을 수행하는 내부 가고, 볼 수 그럼 당신은 여기 -AfterDelay없이 시간이 지나면 선택기를 수행하는 방법은 무엇입니까? (코드 unside)
-(void)playGame{
isButtonPressed=NO;
int minimum=1;
int maximum=4;
int randomTime=(arc4random()%(maximum-minimum))+minimum;
[self performSelector:@selector(ifButtonNotPressed) withObject:nil afterDelay:randomTime];
}
-(void)closingAction{
NSLog(@"Closing Panel automatic");
if (randomFrog==1){
[self performSelector:@selector(animatePanelCloseAction::) withObject:gameImage1_up withObject:gameImage1_down];
}
[self performSelector:@selector(playGame) withObject:nil afterDelay:0.25];
}
-(IBAction)buttonAction:(id)sender{
if (sender == gameButton1 && randomFrog==1){
[self performSelector:@selector(disableAllButtons)];
score=score+1;
isButtonPressed=YES;
[scoreLabel setText:[NSString stringWithFormat:@"Score:%d",score]];
[self performSelector:@selector(closingAction)];
}
}
-(void)ifButtonNotPressed{
if (isButtonPressed==NO){
[self performSelector:@selector(closingAction)];
}
}
의 코드를 볼 수 있습니다.
어떻게 실제 지연 후 전화 할 수 있습니까?!
감사합니다. amir.