본문 바로가기

개발도구/iOS - 아이폰 개발

[아이폰] UIAlertview - iphone alert


UIAlertView* customAlert = [[UIAlertView alloc] initWithTitle:@"MoneyTodayPAD" message:@"머니투데이 신문보기는 뉴스가판대 서비스에서 이용하실수 있습니다. 뉴스가판대로 이동하시겠습니까?" delegate:nil cancelButtonTitle:@"확인" otherButtonTitles:nil];
[customAlert show];
[customAlert autorelease];




 static BOOL diagStat = NO; //,아니오 버튼의 상태를 저장할 임시 변수
 -(class action){

 UIAlertView *confirmDiag = [[UIAlertView alloc] initWithTitle:nil message:@"머니투데이 신문보기는 뉴스가판대 서비스에서 이용하실수 있습니다. 뉴스가판대로 이동하시겠습니까?" delegate:self cancelButtonTitle:NSLocalizedString(@"Yes", @"") otherButtonTitles:NSLocalizedString(@"No", @"아니오"), nil];

   [confirmDiag show];

    while (confirmDiag.hidden == NO && confirmDiag.superview != nil)
        [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01f]];
   
    [confirmDiag release];
       return diagStat;
 
 }

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
   //index 0 : YES , 1 : NO

   if (buttonIndex == 0){
   NSLog(@"1");
   diagStat = YES;

    } else if (buttonIndex == 1) {
       //return NO;
       NSLog(@"2");
       diagStat = NO;

     }