코딩하는 나귀




UIAlertView *WaitPrompt()  

{  

UIAlertView *alert = [[[UIAlertView alloc]   

  initWithTitle:@"Contacting Server\nPlease Wait..."   

  message:nil delegate:nil cancelButtonTitle:nil  

  otherButtonTitles: nil] autorelease];  

[alert show];  

UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc]  

  initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];  

indicator.center = CGPointMake(alert.bounds.size.width / 2,   

  alert.bounds.size.height - 50);  

[indicator startAnimating];  

[alert addSubview:indicator];  

[indicator release];  

// 250ms pause for the dialog to become active...  

int n=0;  

while(n < 250)  

{  

[[NSRunLoop currentRunLoop] limitDateForMode:NSDefaultRunLoopMode];  

Sleep(1);  

n++;  

}  

return alert;  

}


[출처 : http://www.box-of-monkeys.co.uk/index.php?id=29&tp=2&tag=programming]


사용자가 버튼을 누를 때까지 대기하는 경우


UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Contacting Server\nPlease Wait..."

        message:nil

       delegate:nil 

      cancelButtonTitle:@"OK"

      otherButtonTitles:nil];

[alert show];

while ((!alert.hidden) && (alert.superview != nil)) {

[[NSRunLoop currentRunLoop] limitDateForMode:NSDefaultRunLoopMode];

}

[alert release];


응용하면 버튼을 직접 추가하고 일정시간후 활성화 되는 버튼도 가능은 하겠으나 원하는 버튼 스타일이 아마...풉 -_-;