본문 바로가기

ios aos 개발/iPhone

[iPhone] UIAlertView 자동종료

반응형
#pragma mark - alert창 선택시 불리는 함수 
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if([alertView tag]==PHONE && buttonIndex == YES)
    {
        _phone = [_phone stringByAppendingString:@"\n\ncalling...."];
        UIAlertView *alert = [[UIAlertView alloc
                               ]initWithTitle:_phone
                              message:@"waiting"
                              delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
        [alert show];

        //alert 창 자동 종료 되도록 하는 함수 호출 
        [self performSelector:@selector(closeAlert:) withObject:alert afterDelay:1];
        [alert release];
    }
}

-(void)closeAlert:(UIAlertView*)alert
{
    [alert dismissWithClickedButtonIndex:1 animated:YES];
    NSLog(@"close");
}