dismissing a UIAlertView programmatically

后端 未结 5 1560
孤城傲影
孤城傲影 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:23

    You need to set two things.

    1. include your .h file :

    2. please follow below implementation...

       UIAlertView *alert1 = [[UIAlertView alloc]initWithTitle:@"title" message:@"message" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil]; 
            [alert1 show];
            [self performSelector:@selector(dismiss:) withObject:alert1 afterDelay:1.0];
    

    the dismiss method will be...

    -(void)dismiss:(UIAlertView*)alert
    {
        [alert dismissWithClickedButtonIndex:0 animated:YES];
    }
    

    I hope this will help you.

提交回复
热议问题