UIActionSheet UIAlertView

本文详细阐述了iOS应用中用户登录退出流程及弹窗设计实现方式,包括使用UIActionSheet、UIAlertView和UIAlertController展示确认对话框,提供用户选择退出登录或取消操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

#import "LZJContactVC-2.h"

 

@interface LZJContactVC_2 ()<UIActionSheetDelegate,UIAlertViewDelegate>

 

@end

 

@implementation LZJContactVC_2

 

- (void)viewDidLoad {

    [super viewDidLoad];

    

}

 

//退出登录

- (IBAction)loginOut:(id)sender {

//    11111111

//    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"确定要退出登录嘛?" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定退出" otherButtonTitles:nil];

//    

//    [actionSheet showInView:self.view];

    

//    222222222

//    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"确定要退出登录嘛?"  message:@"message" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];

//    

//    [alert show];

//    

//

//    33333333333

//    //第一步:创建控制器

    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"确定要退出嘛?" message:nil preferredStyle:UIAlertControllerStyleActionSheet];

    //第二步:创建按钮

    UIAlertAction *action = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {

//        NSLog(@"点击了取消");

    }];

    

    UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {

    

        [self.navigationController popViewControllerAnimated:YES];

    }];

    //第三步:添加按钮

    [alertVC addAction:action];

    [alertVC addAction:action1];

    //第四步:显示弹框.(相当于show操作)'

    [self presentViewController:alertVC animated:YES completion:nil];

  

    

    

}

 

 

//-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{

//

//    

//    if (buttonIndex == 0) {

//        //退出

//        [self.navigationController popViewControllerAnimated:YES];

//    }

//    

//}

//

//-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

//    

//    if (buttonIndex == 1) {

//        //退出

//        [self.navigationController popViewControllerAnimated:YES];

//    }

//    

//

//}

转载于:https://www.cnblogs.com/liuzhenjie/p/5454619.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值