ios8.3——ios9弹出警告框

在8.3之后,以前的办法就不可以用了,而下面这个方法在8.0之后就已经使用。


NS_ASSUME_NONNULL_BEGIN

//alert的按钮样式
typedef NS_ENUM(NSInteger, UIAlertActionStyle) {
    UIAlertActionStyleDefault = 0,
    UIAlertActionStyleCancel,
    UIAlertActionStyleDestructive
} NS_ENUM_AVAILABLE_IOS(8_0);

//alert控制器的样式,就是就是alert和actionsheet的两种情况
typedef NS_ENUM(NSInteger, UIAlertControllerStyle) {
    UIAlertControllerStyleActionSheet = 0,
    UIAlertControllerStyleAlert
} NS_ENUM_AVAILABLE_IOS(8_0);

//UIAlertAction这个类的属性,也就是设置相关的sheet(和alert两种都是一样,下面将会值介绍一种)
NS_CLASS_AVAILABLE_IOS(8_0) @interface UIAlertAction : NSObject <NSCopying>

//初始化的方法
+ (instancetype)actionWithTitle:(nullable NSString *)title style:(UIAlertActionStyle)style handler:(void (^ __nullable)(UIAlertAction *action))handler;
//相关的属性
@property (nullable, nonatomic, readonly) NSString *title;
@property (nonatomic, readonly) UIAlertActionStyle style;
@property (nonatomic, getter=isEnabled) BOOL enabled;
@end

//UIAlertController类
NS_CLASS_AVAILABLE_IOS(8_0) @interface UIAlertController : UIViewController
//初始化一个方法

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

//属性,标题、信息
@property (nullable, nonatomic, copy) NSString *title; //标题
@property (nullable, nonatomic, copy) NSString *message;//信息
@property (nonatomic, readonly) UIAlertControllerStyle preferredStyle;//样式


//增加动作?这个方法么有用过

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

//属性action是一个数组的类型

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


//偏向,应该是默认的动作

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

//在alert上增textfield

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


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

@end


NS_ASSUME_NONNULL_END
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值