iOS 9.0 - 从UIAlertController操作表中删除顶部栏

时间:2015-10-23 18:13:28

标签: ios ios9 uialertcontroller

使用nil创建操作表时,我看到顶部栏始终显示。这篇SO帖子建议将标题设置为gulp-useref - 这可能适用于iOS 8.0,但我在iOS 9.0上看到了一个顶级栏。

enter image description here

2 个答案:

答案 0 :(得分:5)

message设置为nil

UIAlertController *actionSheet= [UIAlertController
                                 alertControllerWithTitle:nil
                                 message:nil
                                 preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *actionSheetButton1 = [UIAlertAction
                                     actionWithTitle:@"Button 1"
                                     style:UIAlertActionStyleDefault
                                     handler:^(UIAlertAction * action)
                                     {
                                         NSLog(@"Button 1 pressed");
                                     }];
UIAlertAction *actionSheetButton2 = [UIAlertAction
                                     actionWithTitle:@"Button 2"
                                     style:UIAlertActionStyleDefault
                                     handler:^(UIAlertAction * action)
                                     {
                                         NSLog(@"Button 2 pressed");
                                     }];
UIAlertAction *actionSheetButton3 = [UIAlertAction
                                     actionWithTitle:@"Close Button"
                                     style:UIAlertActionStyleCancel
                                     handler:^(UIAlertAction * action)
                                     {
                                         NSLog(@"Close Button pressed");
                                     }];

[actionSheet addAction:actionSheetButton1];
[actionSheet addAction:actionSheetButton2];
[actionSheet addAction:actionSheetButton3];
[self presentViewController:actionSheet animated:YES completion:nil];

enter image description here

答案 1 :(得分:1)

您是否还将message设为nil? 这应该是诀窍,至少它适用于iOS9(iPhone 6):

[UIAlertController alertControllerWithTitle:nil
                                message:nil
                         preferredStyle:UIAlertControllerStyleActionSheet];