iOS6、7、8、9新特性总汇和适配说明 (17)

@property (nonatomic, readonly) NSArray *textFields;

 

@property (nonatomic, copy) NSString *title;

 

@property (nonatomic, copy) NSString *message;

 

@property (nonatomic, readonly) UIAlertControllerStyle preferredStyle;

 

[Format Time: 0.0023 seconds]

简单实用示例:

Crayon Syntax Highlighter v2.7.1

// 1.创建提示框对象,默认是actionSheet效果

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"注意" message:@"我的呈现方式变了" preferredStyle:UIAlertControllerStyleAlert];

 

// 2.创建取消按钮并添加到提示框上

[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {

    

    NSLog(@"取消按钮被点击了");

}]];

 

// 3.呈现提示框

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

1

2

3

4

5

6

7

8

9

10

11

 

// 1.创建提示框对象,默认是actionSheet效果

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"注意" message:@"我的呈现方式变了" preferredStyle:UIAlertControllerStyleAlert];

 

// 2.创建取消按钮并添加到提示框上

[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {

    

    NSLog(@"取消按钮被点击了");

}]];

 

// 3.呈现提示框

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

 

[Format Time: 0.0024 seconds]

 

二、UIPopoverController直接通过present方式呈现

UIViewController.h

Crayon Syntax Highlighter v2.7.1

typedef NS_ENUM(NSInteger, UIModalPresentationStyle) {

    

    UIModalPresentationFullScreen = 0,

    

    UIModalPresentationPageSheet NS_ENUM_AVAILABLE_IOS(3_2),

    

    UIModalPresentationFormSheet NS_ENUM_AVAILABLE_IOS(3_2),

    

    UIModalPresentationCurrentContext NS_ENUM_AVAILABLE_IOS(3_2),

    

    UIModalPresentationCustom NS_ENUM_AVAILABLE_IOS(7_0),

    

    UIModalPresentationOverFullScreen NS_ENUM_AVAILABLE_IOS(8_0),

    

    UIModalPresentationOverCurrentContext NS_ENUM_AVAILABLE_IOS(8_0),

    

    UIModalPresentationPopover NS_ENUM_AVAILABLE_IOS(8_0),

    

    UIModalPresentationNone NS_ENUM_AVAILABLE_IOS(7_0) = -1,

    

};

 

@property (nonatomic,readonly) UIPopoverPresentationController *popoverPresentationController NS_AVAILABLE_IOS(8_0);

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

 

typedef NS_ENUM(NSInteger, UIModalPresentationStyle) {

    

    UIModalPresentationFullScreen = 0,

    

    UIModalPresentationPageSheet NS_ENUM_AVAILABLE_IOS(3_2),

    

    UIModalPresentationFormSheet NS_ENUM_AVAILABLE_IOS(3_2),

    

    UIModalPresentationCurrentContext NS_ENUM_AVAILABLE_IOS(3_2),

    

    UIModalPresentationCustom NS_ENUM_AVAILABLE_IOS(7_0),

    

    UIModalPresentationOverFullScreen NS_ENUM_AVAILABLE_IOS(8_0),

    

    UIModalPresentationOverCurrentContext NS_ENUM_AVAILABLE_IOS(8_0),

    

    UIModalPresentationPopover NS_ENUM_AVAILABLE_IOS(8_0),

    

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zwgywp.html