프로그램/iOS

iOS UIalertView 사용법

잡식성초보 2016. 2. 19. 17:33

테이블 뷰에다가 alert를 사용할때는 태그값이 필요할수도 있다. 버튼 하나만 사용하고 싶으면 @"취소"  부분을 nil 하여주면 됨


UIAlertView *alert = 

[[UIAlertView alloc]initWithTitle:@"타이틀 제목" message:@"말할 메세지" delegate:self cancelButtonTitle:@"취소"otherButtonTitles:@"확인"nil];

alert.tag = 1

        [alert show];


//밑에것은 alert 클릭시 타는 부분

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{

    NSLog(@"alertView : %ld    , %d", buttonIndex, (int)alertView.tag);

    if((int)alertView.tag == 2){

        if (buttonIndex == 1){

         //로직

        }

    } 

}

반응형