2014-01-05 1 views
0

내가이 시도 UIAlert변경 스토리 보드는

을 통해 게임에서 메인 메뉴를 클릭 한 후 주 메뉴로 변경하고자 누르면 :

-(void)gameOver 
{ 
    UIAlertView *alert = [[UIAlertView alloc] 
          initWithTitle:@"Time's up!" 
          message:[NSString stringWithFormat:@"You've scored: %i points!", scoreCounter] 
          delegate:self 
          cancelButtonTitle:nil 
          otherButtonTitles:@"Submit to Leaderboards",@"Play Again",@"Main Menu", nil]; 
    [alert show]; 
} 
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { 
    if (buttonIndex == 1) { 
     [self toMain]; 
    } 
    if (buttonIndex == 2) { 
     [self toMain]; 
    } 
    if (buttonIndex == 3) 
    { 
     [self toMain]; 
    } 

} 
-(void)toMain 
{ 
    mainMenu *main = [[mainMenu alloc] initWithNibName:nil bundle:nil]; 
    [self presentViewController:main animated:YES completion:NULL]; 
} 

전혀 아무것도하지 않습니다 ...

EDIT

[자동 대문] 이후 검은 색 화면으로 바뀌는 버튼 인덱스를 수정했습니다.

+0

당신은 당신의'* 파일 .h'에서' Protocol'를 추가합니까? – Stone

+0

프로토콜을 명시 적으로 선언해도 아무런 영향이 없어야하지만 좋은 생각입니다. – powerj1984

답변

1

버튼 인덱스는 0에서 시작하므로 버튼 3 개로는 buttonIndex == 3 브랜치를 호출 할 수 없습니다.

자료 : Apple Docs on UIAlertView

+0

인덱스 0의 취소 버튼이 아닙니까? – powerj1984

+0

thx, 이제 실제로 뭔가를합니다. 이제 [self to Main] 뒤에 검은 색 화면이 나타납니다. 그게 뭐죠? – Martijn

+0

@ powerj1984 그의 취소 버튼은 다른 SO 질문에 대한 @MartinJ가 아닌 – coneybeare

관련 문제