Ich habe einen UIAlertController:iOS 10: UIAlertController nur zeigt eine Aktion
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];
Warum ist nur eine dieser Aktionen zeigt, wenn das Menü auf dem iPad angezeigt wird? Ich testete dies auf einem 10.1 iPad Sim und Gerät (funktioniert nicht auf beide), sowie eine 10.1 iPhone 7 Sim und Gerät (funktioniert auf allen iPhones).
Dies hat funktioniert, seit ich es nach der Veröffentlichung von iOS 8 behoben (setTintColor wurde hinzugefügt). Beim Debuggen werden "7 Aktionen" hinzugefügt, daher bin ich mir nicht sicher, wohin ich von hier für das UIAlertControllerStyleActionSheet gehen soll, welches die gewünschte Anzeigeoption ist. UIAlertControllerStyleAlert zeigt alle 7, aber ich mag das alte UIAlertControllerStyleActionSheet Look.
Nicht verknüpft, aber versuchen Sie nicht, das Aktionsblatt aus den Aktionen des Aktionsblatts zu entfernen. Es wird automatisch ausgeblendet, wenn eine Schaltfläche angetippt wird. – rmaddy
Ich habe ein ähnliches Problem, da nur meine oberste Aktion angezeigt wird, wenn sie auf dem Simulator ausgeführt wird, aber alle Aktionen werden angezeigt, wenn sie auf dem Gerät ausgeführt werden. Ich versuche nicht, die Tönungsfarbe oder irgendeinen Aspekt des UIAlertControllers zu ändern, und der Anzeigemodus ist ActionSheet. Ist das ein Fehler in den Simulatoren? Sie alle weisen das gleiche Problem auf. –
@RonB. Ich ging einfach mit UIAlertControllerStyleAlert und nannte es einen Tag. Meine neue Version ist bereits im Laden, da die ActionSheet-Popup-Funktion seit iOS 8 fehlerhaft ist. Hey, hättest du etwas dagegen, diese Frage zu beantworten, wenn du glaubst, dass sie gültig ist? Jemand hat eine legitime Frage abgelehnt und es war irgendwie nervig. Wenn eine Frage negative Stimmen hat, hilft sie nicht, einer anderen Person auf einen Blick zu helfen – whyoz