您的位置:首页 > 移动开发 > IOS开发

ios8.3——ios9弹出警告框

2015-07-13 17:23 435 查看
在8.3之后,以前的办法就不可以用了,而下面这个方法在8.0之后就已经使用。

NS_ASSUME_NONNULL_BEGIN

//alert的按钮样式

typedef NS_ENUM(NSInteger, UIAlertActionStyle) {

UIAlertActionStyleDefault = 0,

UIAlertActionStyleCancel,

UIAlertActionStyleDestructive

} NS_ENUM_***AILABLE_IOS(8_0);

//alert控制器的样式,就是就是alert和actionsheet的两种情况

typedef NS_ENUM(NSInteger, UIAlertControllerStyle) {

UIAlertControllerStyleActionSheet = 0,

UIAlertControllerStyleAlert

} NS_ENUM_***AILABLE_IOS(8_0);

//UIAlertAction这个类的属性,也就是设置相关的sheet(和alert两种都是一样,下面将会值介绍一种)

NS_CLASS_***AILABLE_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_***AILABLE_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_***AILABLE_IOS(9_0);

//在alert上增textfield

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

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

@end

NS_ASSUME_NONNULL_END
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: