【发布时间】:2016-11-03 19:41:20
【问题描述】:
我有一个 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];
为什么在 iPad 上显示菜单时只显示这些操作之一?我在 10.1 版 iPad sim 卡和设备(两者均不适用)以及 10.1 版 iPhone 7 sim 卡和设备(适用于所有 iPhone)上对此进行了测试。
自从我在 iOS 8 发布后修复它以来一直有效(添加了 setTintColor)。调试它显示添加了“7 个操作”,所以我不确定从这里去哪里获取 UIAlertControllerStyleActionSheet,这是所需的显示选项。 UIAlertControllerStyleAlert 显示所有 7 个,但我喜欢旧的 UIAlertControllerStyleActionSheet 外观。
【问题讨论】:
-
不相关但不要尝试从任何操作表的操作中消除操作表。当它点击一个按钮时它会自动关闭。
-
我有一个有点类似的问题,在模拟器上运行时只会显示我的顶级操作,但在设备上运行时会显示所有操作。我没有尝试更改色调颜色或 UIAlertController 的任何方面,并且显示模式是 ActionSheet。这是模拟器中的错误吗?他们都表现出同样的问题。
-
@RonB。我刚刚使用 UIAlertControllerStyleAlert 并称之为一天。我的新版本已经在商店里了,因为自从 iOS 8 以来 ActionSheet 弹出功能一直存在问题。为什么要打它。嘿,如果你认为这个问题是有效的,你介意投票吗?有人对一个合理的问题投了反对票,这有点烦人。当一个问题有反对票时,它就不会帮助另一个人快速浏览
标签: ios objective-c ipad uialertcontroller