iOS开发中弹窗的方式

由于iOS系统的不断更新, 所以导致很多就方法慢慢的被淘汰,但是在一些旧的项目中仍然在使用, 这就到时很多初学者容易对新旧方法混淆不清, 下面介绍一下关于弹窗的新旧不同方式及其使用方法, 废话不多说,  上代码
//  ViewController.m
//  弹窗的四中种形式
//
//  Created by Wangjunling on 16/3/9.
//  Copyright © 2016年 Wangjunling. All rights reserved.
//

#import "ViewController.h"

@interface ViewController () <UIAlertViewDelegate, UIActionSheetDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    //[self test1];// iOS8之前屏幕中间弹窗
//    [self test2];// iOS8之前屏幕底部弹窗
//    [self test3];// iOS8之后屏幕中间弹窗
    [self test4];// iOS8之后屏幕底部弹窗
}

#pragma mark 方法1 iOS8之前的弹窗方式,在屏幕中间弹窗
- (void)test1{
    // 1.创建一个中间弹框,有“取消”和“确定按钮”,设置代理为当前控制器,由控制器监听点击了“取消”还是“确定”按钮
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"点击了屏幕" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    //2显示
    [alert show];
}
#pragma mark UIAlertViewDelegate 代理方法, 监听方法1中出现的弹框中的按钮点击,控制器来监听点击了取消还是确定按钮
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    // 3处理点击事件
    if (buttonIndex == 0) {
        NSLog(@"点击了取消按钮");
    } else {
        NSLog(@"点击了确定按钮");
    }
}
#pragma mark 方法2 iOS8之前的弹窗方式,在屏幕底部弹窗
- (void)test2 {
    //1创建底部弹窗
    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"点击了屏幕" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"确认" otherButtonTitles:nil, nil];
    //2显示
    [sheet showInView:self.view];
}
#pragma mark 实现actionsheet 代理
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    //3处理点击事件
    if (buttonIndex == 0) {
        NSLog(@"点击了取消按钮");
    } else {
        NSLog(@"点击了确定按钮");
    }
}

#pragma mark 方法3 用在IOS8以后,没有代理。点击按钮时要执行的操作放在了block中,因此不需要设置代理
- (void)test3{
    // 1.创建弹框控制器, UIAlertControllerStyleAlert这个样式代表弹框显示在屏幕中央
    UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:@"提示" message:@"点击了屏幕" preferredStyle:UIAlertControllerStyleAlert];
    // 2.添加取消按钮,block中存放点击了“取消”按钮要执行的操作
    UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
        NSLog(@"点击了取消按钮");
    }];
    
    UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        
        NSLog(@"点击了确定按钮");
        
    }];
    // 3.将“取消”和“确定”按钮加入到弹框控制器中
    [alertVc addAction:cancle];
    [alertVc addAction:confirm];

    // 4.控制器 展示弹框控件,完成时不做操作
    
    [self presentViewController:alertVc animated:YES completion:^{
        
        nil;
        
    }];
    
}
#pragma mark 方法4用在IOS8以后,弹框的样式变为“UIAlertControllerStyleActionSheet”, 弹框出现在屏幕底部
- (void)test4 {
    UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:@"提示" message:@"点击了屏幕" preferredStyle:UIAlertControllerStyleActionSheet];
   
    UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
        NSLog(@"点击了取消");
    }];
    UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
        NSLog(@"点击了确定");
    }];
    /*关于UIAlertActionStyle有三种样式 
     UIAlertActionStyleDefault  , 默认样式
     UIAlertActionStyleCancel,      取消
     UIAlertActionStyleDestructive, 有毁灭性的操作是使用, 呈现红色
     */
    [alertVc addAction:cancle];
    [alertVc addAction:confirm];
    
    [self presentViewController:alertVc animated:YES completion:^{
        
        nil;
        
    }];
    
}
@end

IVMS-4200用户手册云盘是指将IVMS-4200软件用户手册存储在云盘上的一种方式。IVMS-4200是海康威视(Hikvision)公司开发的一款视频监控管理软件,用户手册是为了帮助用户更好地了解和使用该软件而编写的说明书。 云盘是指通过网络将数据存储在云服务器上,用户可以通过网络访问、传输和管理云盘中的数据。将IVMS-4200用户手册存储在云盘上有以下几个优点: 首先,便捷性。用户无需下载和安装软件,只需通过浏览器登录云盘账号,就可以随时随地查阅用户手册。无论在何地、何时,只要有网络连接,就能方便地获取手册内容。 其次,共享性。云盘是一个共享的平台,多个用户可以同时访问同一个云盘上的用户手册。这就方便了团队协作和知识共享,不同用户之间可以互相学习和交流使用经验。 再次,实时更新。云盘上存储的用户手册可以随时进行更新和替换。开发者可以在云盘上上传新版本的手册,用户只需刷新页面即可查看最新的内容,减少了传统的纸质手册印刷、分发和更新的时间和成本。 最后,安全性。云盘通常具有安全机制,如账号密码验证、数据加密等,确保用户手册的安全性和隐私性。即使用户的电脑或移动设备丢失或损坏,手册仍然安全保存在云盘上,用户不会丢失使用说明。 综上所述,将IVMS-4200用户手册存储在云盘上,可以提高使用者的便捷性、共享性、实时更新性和安全性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值