iOS:UIAlertController 弹出提示选择窗的实现示例

-(void)cancelAction{
    
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"是否确定放弃回复?" preferredStyle:UIAlertControllerStyleAlert];
    [self presentViewController:alertController animated:YES completion:nil];
    [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        [self.navigationController popViewControllerAnimated:YES]; //这里写选择确定之后的操作
        
    }]];
    [alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
         NSLog(@“用户选择继续”);  //这里写选择取消之后的操作
    }]];
    
}

当需要弹窗提示选择时,可以调用此方法,即简单创建和显示弹出窗。

猜你喜欢

转载自blog.csdn.net/lyxleft/article/details/80360550
今日推荐