gpt4 book ai didi

iOS 10 : UIAlertController only showing one action

转载 作者:行者123 更新时间:2023-12-01 17:48:14 24 4
gpt4 key购买 nike

我有一个 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];

enter image description here

为什么在 iPad 上显示菜单时只显示这些操作之一?我在 10.1 iPad sim 卡和设备(两者均不适用)以及 10.1 iPhone 7 sim 卡和设备(适用于所有 iPhone)上对此进行了测试。

这一直有效,因为我在 iOS 8 发布后修复了它(添加了 setTintColor)。调试它显示添加了“7 个操作”,所以我不确定从这里去哪里获取 UIAlertControllerStyleActionSheet,这是所需的显示选项。 UIAlertControllerStyleAlert 显示所有 7 个,但我喜欢旧的 UIAlertControllerStyleActionSheet 外观。

最佳答案

在 iOS 10 下,显示 UIAlertController如果您尝试设置警报 Controller View 的 tintColor,则“ActionSheet”样式无法正常工作.我在为 iOS 10 更新我的应用程序时遇到了这个问题。我向 Apple 提交了错误报告。

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

[actionSheet.view setTintColor:[UIColor blackColor]];

在 iOS 10 下。

与此问题无关,您的代码错误地尝试从各种警报操作中解除警报 Controller 。不要这样做。警报将自动解除。您需要删除所有调用:
[actionSheet dismissViewControllerAnimated:YES completion:nil];

关于iOS 10 : UIAlertController only showing one action,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40409919/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com