iOS 系统弹窗 自动消失

-(void)showAlertView:(NSString*)message
{
    
    UIAlertView *toast = [[UIAlertView alloc] initWithTitle:nil
                                                    message:message
                                                   delegate:nil
                                          cancelButtonTitle:nil
                                          otherButtonTitles:nil, nil];
    
    [toast show];
    
    double duration = 1;
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [toast dismissWithClickedButtonIndex:0 animated:YES];
    });
    
}

猜你喜欢

转载自blog.csdn.net/sinat_23907467/article/details/73325736