zoukankan      html  css  js  c++  java
  • iOS开发 提示框- UIAlertController(是UIAlertView和UIActionSheet的合二为一)

     目前最新的Xcode版本,已经不能再用UIAlertView,已被UIAlertController取代,本文是自己学习UIAlertController的一个例子,只供参考!希望与各位共同进步。

    #import <UIKit/UIKit.h> 

    @interface ViewController : UIViewController

    /**

     *  按钮

     */

    @property(strong,nonatomic) UIButton *MyButton;

    @end

    #import "ViewController.h"

    @interface ViewController ()

    @end

    @implementation ViewController

    - (void)viewDidLoad

    {

        [super viewDidLoad];

        //创建button

        self.MyButton=[[UIButton alloc] initWithFrame:CGRectMake(100, 100, 200,50)];

        self.MyButton.backgroundColor=[UIColor redColor];

        [self.MyButton setTitle:@"按钮" forState:UIControlStateNormal];

    //触发事件

        [self.MyButton addTarget:self action:@selector(Test) forControlEvents:UIControlEventTouchUpInside];

        [self.view addSubview:self.MyButton];

    }

     -(void)Test

    {

        UIAlertController *MyAlertController=[UIAlertController alertControllerWithTitle:@"系统提示" message:@"你真的要用4G流量聊天吗?" preferredStyle:UIAlertControllerStyleAlert];

        //创建actions

        UIAlertAction *MyAlertAction=[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action)

        {

            NSLog(@"确定");

        }];

        

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

        {

            NSLog(@"取消");

        }];

        [MyAlertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField)

        {

            textField.backgroundColor=[UIColor whiteColor];

        }];

       

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

        [MyAlertController addAction:MyAlertAction];

        [MyAlertController addAction:MyAlertAction1];

  • 相关阅读:
    服务器RAID5阵列掉了两块盘恢复数据过程
    sql server数据库错误数据恢复过程
    raid崩溃导致存储虚拟化平台数据丢失
    详解MBR分区结构以及GPT分区结构
    存储硬件故障如何恢复数据库
    服务器raid常见故障解决方案
    误删除VMware虚拟机vmdk文件的恢复方法
    HP P2000 服务器数据恢复+服务器数据恢复通用办法
    DELL EqualLogic PS6100存储数据丢失的解决方案
    IBM DS4800服务器RAID信息丢失数据恢复方法
  • 原文地址:https://www.cnblogs.com/tmf-4838/p/5263055.html
Copyright © 2011-2022 走看看