dismissing a UIAlertView programmatically

后端 未结 5 1559
孤城傲影
孤城傲影 2021-02-13 17:12

I need help on dismissing a UIAlertView programmatically. Currently I have this

UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:@\"title\" message:@

5条回答
  •  孤街浪徒
    2021-02-13 17:18

    you should display it first:

    UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:@"title" message:@"message" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
        [alert1 show];
    

    then in delegate method

    - (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex{
        if(buttonIndex==0){
         // do something
        }
    }
    

提交回复
热议问题