2011-10-31 6 views
0

질문이 잘 형성되어 있는지 잘 모르겠습니다. 그래서 나는 30 초 동안 시작 응용 프로그램에 표시된 uialertview 있습니다. 이 uialertview에는 사용자가 경고를 클릭하고 해제 할 수있는 "ok"버튼이 있습니다. 사용자가이 버튼을 30 초 동안 클릭하지 않으면 경고가 해제됩니다. 다음 코드는 .. 부울을 사용하여 응용 목적 c의 상태를 확인하십시오.

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome" 
               message:@"Welcome!" 
               delegate:nil 
             cancelButtonTitle:@"OK" 
             otherButtonTitles:nil]; 
[alert setDelegate:self]; 
[alert show]; 

dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC*30.0); 
dispatch_after(delay, dispatch_get_main_queue(), ^{ 
[alert release]; 

} 

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { 

} 

그래서 사용자가 [확인]을 클릭 아닌지 확인하기 위해 부울하여 컨트롤을 구현해야

... 은 u는 나를 도울 수 있습니까? 나는 객관적으로 새로운 c :) 고마워! 다음과 같이

답변

0

이 경고보기보기 : 가 ISD는 BOOL 값입니다 가정

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome" 
               message:@"Welcome!" 
               delegate:self 
             cancelButtonTitle:@"OK" 
             otherButtonTitles:nil]; 
[alert setTag:1000]; 
[alert show]; 
isD = NO; 

dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC*5.0); 
dispatch_after(delay, dispatch_get_main_queue(), ^{ 

    if (!isD) { 
     [alert dismissWithClickedButtonIndex:0 animated:YES]; 
    } 
}); 
[alert release]; 

(.H 파일에서 클래스 멤버로 선언) 그리고 = YES가 가지고있는 UIAlertViewDelegate 방법을

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex 
{ 
    if(alertView.tag == 1000) 
    { 
     isD = YES; 
    } 
} 
+0

ISD 쓰기 경고 : 시맨틱 문제 : 'BOOL'(일명 'signed char')에서 'BOOL *'(일명 'signed char *')에 할당되는 호환되지 않는 정수 대 포인터 변환 – JackTurky

+0

BOOL이 포인터가 아닙니다. 헤더 파일에 어떻게 선언 했나요? BOOL * isD; 또는 BOOL isD; 두 번째 것은 정확합니다. – Ilanchezhian

+0

완벽 : 나는 포인터로 선언했다. :) – JackTurky

관련 문제