zoukankan      html  css  js  c++  java
  • UIAlertController

    //

    //  UIAlertController.h

    //  UIKit

    //

    //  Copyright (c) 2014-2015 Apple Inc. All rights reserved.

    //

    #import <UIKit/UIViewController.h>//继承自UIViewController

    NS_ASSUME_NONNULL_BEGIN

    #pragma mark======== 两个枚举 ====

    typedef NS_ENUM(NSInteger, UIAlertActionStyle) {

        UIAlertActionStyleDefault = 0,

        UIAlertActionStyleCancel,

        UIAlertActionStyleDestructive

    } NS_ENUM_AVAILABLE_IOS(8_0);//UIAlertActionStyle 的枚举

    typedef NS_ENUM(NSInteger, UIAlertControllerStyle) {

        UIAlertControllerStyleActionSheet = 0,

        UIAlertControllerStyleAlert

    } NS_ENUM_AVAILABLE_IOS(8_0); //弹窗样式的枚举

    #pragma mark======== UIAlertAction ====

    NS_CLASS_AVAILABLE_IOS(8_0) @interface UIAlertAction : NSObject <NSCopying> //UIAlertAction类

    + (instancetype)actionWithTitle:(nullable NSString *)title style:(UIAlertActionStyle)style handler:(void (^ __nullable)(UIAlertAction *action))handler; //UIAlertAction实例化的单例  (核心部分)

    @property (nullable, nonatomic, readonly) NSString *title; //注册事件的标题

    @property (nonatomic, readonly) UIAlertActionStyle style; //弹窗的样式

    @property (nonatomic, getter=isEnabled) BOOL enabled; //是否可用

    @end

    #pragma mark ========  UIAlertController =======

    NS_CLASS_AVAILABLE_IOS(8_0) @interface UIAlertController : UIViewController //继承自UIViewController

    //UIAlertController 实例化的単例 

    //instancetype 对于非关联返回类型,instancetype可以让编译器知道,返回类的所在类型 

    + (instancetype)alertControllerWithTitle:(nullable NSString *)title message:(nullable NSString *)message preferredStyle:(UIAlertControllerStyle)preferredStyle;

    //与UIAlertAction类建立联系的方法

    - (void)addAction:(UIAlertAction *)action; 

    //拿到注册的所有事件

    @property (nonatomic, readonly) NSArray<UIAlertAction *> *actions; 

    //与最开始的枚举相对应

    @property (nonatomic, strong, nullable) UIAlertAction *preferredAction NS_AVAILABLE_IOS(9_0); 

    // 与UITextField建立联系的注册事件

    - (void)addTextFieldWithConfigurationHandler:(void (^ __nullable)(UITextField *textField))configurationHandler;

    //拿到建立注册事件的所有文本输入框

    @property (nullable, nonatomic, readonly) NSArray<UITextField *> *textFields;

    @property (nullable, nonatomic, copy) NSString *title;

    @property (nullable, nonatomic, copy) NSString *message;

    //与最开始的枚举相对应

    @property (nonatomic, readonly) UIAlertControllerStyle preferredStyle;

    @end

    NS_ASSUME_NONNULL_END

  • 相关阅读:
    不停机还能替换代码?6年的 Java程序员表示不可思议
    redis 分布式锁的 5个坑,真是又大又深
    一口气说出 4种 LBS “附近的人” 实现方式,面试官笑了
    真没想到,Springboot能这样做全局日期格式化,有点香!
    springboot + aop + Lua分布式限流的最佳实践
    不可思议的hexo,五分钟教你免费搭一个高逼格技术博客
    Redis开发运维的陷阱及避坑指南
    Jar包一键重启的Shell脚本及新服务器部署的一些经验
    与Redis的初次相识,Redis安装、启动与配置
    SpringBoot项目中应用Jedis和一些常见配置
  • 原文地址:https://www.cnblogs.com/dreamDeveloper/p/6045237.html
Copyright © 2011-2022 走看看