iOS弹出提示选择窗和登录框代码示例:UIAlertController——UIAlertView

本文介绍了如何使用UIAlertController在iOS应用中创建简单的选择弹窗和带有输入文本框的登录框。通过添加文本框、取消与登录按钮及相应处理,实现了登录功能,并提供代码示例。为了提升用户体验,还提到了添加额外验证的可能。
摘要由CSDN通过智能技术生成
-(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(@“用户选择继续”);  //这里写选择取消之后的操作
    }]];
    
}

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

上述代码是最简单的一种选择窗,即alertView。类似效果:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值