iOS 10:UIAlertController只显示一个动作

why*_*yoz 1 objective-c ipad ios uialertcontroller

我有一个UIAlertController:

UIAlertController *actionSheet = [UIAlertController
                                          alertControllerWithTitle:@"Options"
                                          message:@""
                                          preferredStyle:UIAlertControllerStyleAlert];

        UIAlertAction *start = [UIAlertAction
                             actionWithTitle:@"Start"
                             style:UIAlertActionStyleDefault
                             handler:^(UIAlertAction * action)
                             {

                                 [self DisplayAlert:@"" textval:@"You are about to start. Would you like to continue?"];
                                 [actionSheet dismissViewControllerAnimated:YES completion:nil];
                             }];
        UIAlertAction *idle = [UIAlertAction
                             actionWithTitle:@"Idle"
                             style:UIAlertActionStyleDefault
                             handler:^(UIAlertAction * action)
                             {

                                 [self DisplayAlert:@"" textval:@"You are about to idle. Would you like to continue?"];
                                 [actionSheet dismissViewControllerAnimated:YES completion:nil];
                             }];
        UIAlertAction *stop = [UIAlertAction
                             actionWithTitle:@"Stop"
                             style:UIAlertActionStyleDefault
                             handler:^(UIAlertAction * action)
                             {

                                 [self DisplayAlert:@"" textval:@"You are about to stop. Would you like to continue?"];
                                 [actionSheet dismissViewControllerAnimated:YES completion:nil];
                             }];
        UIAlertAction *enable = [UIAlertAction
                               actionWithTitle:@"Enable"
                               style:UIAlertActionStyleDefault
                               handler:^(UIAlertAction * action)
                               {

                                   [self DisplayAlert:@"" textval:@"You are about to enable. Would you like to continue?"];
                                   [actionSheet dismissViewControllerAnimated:YES completion:nil];
                               }];

        UIAlertAction *disable = [UIAlertAction
                               actionWithTitle:@"Disable"
                               style:UIAlertActionStyleDefault
                               handler:^(UIAlertAction * action)
                               {

                                   [self DisplayAlert:@"" textval:@"You are about to disable. Would you like to continue?"];
                                   [actionSheet dismissViewControllerAnimated:YES completion:nil];
                               }];

        UIAlertAction *clear = [UIAlertAction
                               actionWithTitle:@"Clear"
                               style:UIAlertActionStyleDefault
                               handler:^(UIAlertAction * action)
                               {

                                   [self DisplayAlert:@"" textval:@"You are about to clear. Would you like to continue?"];
                                   [actionSheet dismissViewControllerAnimated:YES completion:nil];
                               }];
        UIAlertAction *cancel = [UIAlertAction
                             actionWithTitle:@"Cancel"
                             style:UIAlertActionStyleDestructive
                             handler:^(UIAlertAction * action)
                             {
                                 [actionSheet dismissViewControllerAnimated:YES completion:nil];
                             }];


        [actionSheet addAction:start];
        [actionSheet addAction:idle];
        [actionSheet addAction:stop];
        [actionSheet addAction:enable];
        [actionSheet addAction:disable];
        [actionSheet addAction:clear];
        [actionSheet addAction:cancel];
        [actionSheet setModalPresentationStyle:UIModalPresentationPopover];
        [actionSheet.view setTintColor:[UIColor blackColor]];
        UIPopoverPresentationController *popPresenter = [actionSheet popoverPresentationController];
        popPresenter.barButtonItem = wellControlItem;
        [appDelegate.splitViewController presentViewController:actionSheet animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

为什么在iPad上显示菜单时只显示其中一个操作?我在10.1的iPad sim和设备上测试了这个(没有工作),以及10.1 iPhone 7 SIM和设备(适用于所有iPhone).

这是因为我在iOS 8发布后修复了它(添加了setTintColor).调试这个显示添加了"7个动作",所以我不知道从哪里去UIAlertControllerStyleActionSheet,这是所需的显示选项. UIAlertControllerStyleAlert显示所有7但我喜欢旧的UIAlertControllerStyleActionSheet外观.

rma*_*ddy 5

在iOS 10下,UIAlertController如果您尝试设置警报控制器视图,则显示带有"ActionSheet"样式的a无法正常工作tintColor.我在更新iOS 10应用时遇到了这个问题.我向Apple提交了一个错误报告.

所以你的主要问题将通过不调用来解决:

[actionSheet.view setTintColor:[UIColor blackColor]];
Run Code Online (Sandbox Code Playgroud)

在iOS 10下.

与此问题无关,您的代码错误地尝试从各种警报操作中解除警报控制器.不要这样做.警报将自动解除.您需要删除所有来电:

[actionSheet dismissViewControllerAnimated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)