iOS UIAlertController控件
发布日期:2021-05-14 01:35:58 浏览次数:13 分类:精选文章

本文共 3401 字,大约阅读时间需要 11 分钟。

UIAlertController������UIAlertView���UIActionSheet������������������������������������������������������������������������������������������������������UIAlertControllerStyleAlert���UIAlertControllerStyleActionSheet���������������������������������������������������������������

1. UIAlertControllerStyleAlert ������

������������������������������������������������������������������������������������������������������������������������������UIAlertControllerStyleAlert������������������

- (void)onAlertTwoAction:(UIButton *)sender {    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"������"                                                               message:@"������������������"                                                              preferredStyle:UIAlertControllerStyleAlert];        [alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {        textField.placeholder = @"���������";    }];        [alert addAction:[UIAlertAction actionWithTitle:@"������"                                          style:UIAlertActionStyleDefault                                          handler:^(UIAlertAction *action) {        NSLog(@"text = %@", alert.textFields.firstObject.text);        NSLog(@"������������");    }]];        [alert addAction:[UIAlertAction actionWithTitle:@"������"                                          style:UIAlertActionStyleCancel                                          handler:^(UIAlertAction *action) {        NSLog(@"������������");    }];        [self presentViewController:alert                    animated:YES                    completion:^{        NSLog(@"alert completion");    }];}

2. UIAlertControllerStyleActionSheet ������

������������������������������������������������������������������������������������������UIAlertControllerStyleActionSheet������������������

- (void)onActionSheetAction:(UIButton *)sender {    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"������"                                                               message:@"������������������"                                                              preferredStyle:UIAlertControllerStyleActionSheet];        [alert addAction:[UIAlertAction actionWithTitle:@"���������"                                          style:UIAlertActionStyleDefault                                          handler:^(UIAlertAction *action) {        NSLog(@"���������");    }]];        [alert addAction:[UIAlertAction actionWithTitle:@"���������"                                          style:UIAlertActionStyleDefault                                          handler:^(UIAlertAction *action) {        NSLog(@"���������");    }]];        [alert addAction:[UIAlertAction actionWithTitle:@"������"                                          style:UIAlertActionStyleCancel                                          handler:^(UIAlertAction *action) {        NSLog(@"������������");    }];        [self presentViewController:alert                    animated:YES                    completion:nil];}

ULAReceiverstyleAlert���UIActionSheet���������������������������������������������������������������������������������������������������������������������������������������������cede tasks���������������������������������������������������������������������������������������������������������������������������������������������������������������

上一篇:iOS UIScrollView控件
下一篇:iOS UIPickerView和UIDatePicker控件

发表评论

最新留言

做的很好,不错不错
[***.243.131.199]2025年04月16日 14时42分02秒