我有一个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外观。
答案 0 :(得分:5)
在iOS 10下,显示UIAlertController
样式为" ActionSheet"如果您尝试设置警报控制器视图tintColor
,则无法正常工作。我在更新iOS 10应用时遇到了这个问题。我向Apple提交了一份错误报告。
因此,您的主要问题将通过不致电来解决:
[actionSheet.view setTintColor:[UIColor blackColor]];
在iOS 10下。
与此问题无关,您的代码错误地尝试从各种警报操作中解除警报控制器。不要这样做。警报将自动解除。您需要删除所有来电:
[actionSheet dismissViewControllerAnimated:YES completion:nil];