iPhone의 cocos2d 레이어에 UialertView를 어떻게 표시하려면?
-
19-09-2019 - |
문제
내 게임에 레이어가 있습니다. 게임을 마치면 게임을 다시 시작하거나 금지하기위한 UialertView를 사용자에게 보여주고 싶습니다. 그러나 그것은 작동하지 않습니다. 또한 대의원 UialertViewDelegate에 레이어를 제공합니다.
솔루션이 있습니까?
내 코드는 다음과 같습니다.
-(void)gameFinished{
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
[self unschedule:@selector(checkForCollision)];
[self unschedule:@selector(dropObject)];
[self stopBackgroundMusic];
[self startNewForegroundMusic:@"GameOver" ofType:@"caf"];
[self playForegroundMusic];
[[Director sharedDirector] pause];
UIAlertView *view=[[UIAlertView alloc] initWithTitle:@"Game Finished" message:@"Want to play again?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes"];
[view show];
[view release];
}
해결책
코드가 충돌합니까, 아니면 표시되지 않습니까?
당신은 줄에 약간의 오류가 있습니다
[[UIAlertView alloc] initWithTitle:@"Game Finished"
message:@"Want to play again?"
delegate:self cancelButtonTitle:@"No"
otherButtonTitles:@"Yes"]
이것은해야합니다
[[UIAlertView alloc] initWithTitle:@"Game Finished"
message:@"Want to play again?"
delegate:self cancelButtonTitle:@"No"
otherButtonTitles:@"Yes", Nil]
참고 : 마지막 매개 변수는 변수 인수이므로 종료해야합니다.
다른 팁
감독이 일시 중지되기 전에 알림 뷰를 보여주십시오.
제휴하지 않습니다 StackOverflow