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
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
相关文章推荐
- iOS8使用TestFlight进行内部测试功能尝鲜
- iOS 第三方库(1)
- 常用iOS第三方库以及XCode插件介绍
- iOS设计模式——Category
- Json解析字符串的类型总结--IOS
- iOS设计模式-抽象工厂
- iOS 支付宝 集成
- PhoneGap开发对策:如何通过苹果审核
- 支付宝 iOS SDK 官方下载页面
- iOS 中的 NSTimer
- JS判断客户端是否是iOS或者Android
- iOS真机沙盒文件查看 图片批量存储/获取/删除
- 程序日志--ios“文字长度--button与label的交互”程序
- 常用的iOS开发或者优化的小工具
- ios证书制作与打包发布
- iOS数据 分割代码
- iOS中通知传值的使用
- IOS block 记录
- iOS导航控制器使用interactivePopGestureRecognizer导致导航栏标题可能层次错乱的问题解决
- iOS开发系列--通讯录、蓝牙、内购、GameCenter、iCloud、Passbook系统服务开发汇总