在线直播系统源码,弹出警告/提示类弹窗

在线直播系统源码,弹出警告/提示类弹窗实现的相关代码

 

//
//  ViewController.m
//  001-UIAlertView
//
//  Created by lujun on 2021/6/3.
//
#import "ViewController.h"
@interface ViewController ()
- (IBAction)rightClick:(id)sender;
@end
@implementation ViewController
- (IBAction)clck2:(id)sender {
    
    
    
//    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"标题" message:@"消息" delegate:self cancelButtonTitle:@"取消按钮" otherButtonTitles:@"其他按钮标题", nil];
//
//    [alert show];
    
    //1.创建UIAlertControler
  
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"标题" message:@"这是一些信息" preferredStyle:UIAlertControllerStyleAlert];
    /*
     参数说明:
     Title:弹框的标题
     message:弹框的消息内容
     preferredStyle:弹框样式:UIAlertControllerStyleAlert
     */
    
    //2.添加按钮动作
    //2.1 确认按钮
    UIAlertAction *conform = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"点击了确认按钮");
    }];
    //2.2 取消按钮
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"点击了取消按钮");
    }];
    //2.3 还可以添加文本框 通过 alert.textFields.firstObject 获得该文本框
//    [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
//       textField.placeholder = @"请填写您的反馈信息";
//  }];
 
    //3.将动作按钮 添加到控制器中
    [alert addAction:conform];
    [alert addAction:cancel];
    
    //4.显示弹框
    [self presentViewController:alert animated:YES completion:nil];
    
    
}
- (IBAction)leftClick:(id)sender {
    
    
//    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"标题" message:@"消息" delegate:self cancelButtonTitle:@"取消按钮" otherButtonTitles:@"其他按钮标题", nil];
//
//    [alert show];
    
    //1.创建UIAlertControler
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"标题" message:@"这是一些信息" preferredStyle:UIAlertControllerStyleAlert];
    /*
     参数说明:
     Title:弹框的标题
     message:弹框的消息内容
     preferredStyle:弹框样式:UIAlertControllerStyleAlert
     */
    
    //2.添加按钮动作
    //2.1 确认按钮
    UIAlertAction *conform = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"点击了确认按钮");
    }];
    //2.2 取消按钮
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"点击了取消按钮");
    }];
    //2.3 还可以添加文本框 通过 alert.textFields.firstObject 获得该文本框
    [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
       textField.placeholder = @"请填写您的反馈信息";
  }];
 
    //3.将动作按钮 添加到控制器中
    [alert addAction:conform];
    [alert addAction:cancel];
    
    //4.显示弹框
    [self presentViewController:alert animated:YES completion:nil];
    
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
}
- (IBAction)rightClick:(id)sender {
    //1.创建Controller
    UIAlertController *alertSheet = [UIAlertController alertControllerWithTitle:@"标题" message:@"一些信息" preferredStyle:UIAlertControllerStyleActionSheet];
    /*
     参数说明:
     Title:弹框的标题
     message:弹框的消息内容
     preferredStyle:弹框样式:UIAlertControllerStyleActionSheet
     */
    
    //2.添加按钮动作
    UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"项目1" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"点击了项目1");
    }];
    UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"项目2" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"点击了项目2");
    }];
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"点击了取消");
    }];
    //3.添加动作
    [alertSheet addAction:action1];
    [alertSheet addAction:action2];
    [alertSheet addAction:cancel];
    
    //4.显示sheet
    [self presentViewController:alertSheet animated:YES completion:nil];
    
    
}
@end

以上就是在线直播系统源码,弹出警告/提示类弹窗实现的相关代码, 更多内容欢迎关注之后的文章

 

posted @ 2021-10-27 14:22  云豹科技-苏凌霄  阅读(137)  评论(0编辑  收藏  举报