【发布时间】:2015-02-12 21:05:32
【问题描述】:
iOS 8 之前的版本允许我创建一个UIActionsheet,它会显示一组按钮、一些空间,然后是一个取消按钮。像这样的:
但是在 iOS 8 中,当我尝试创建相同的外观时,我最终会得到如下所示的内容:
iOS 8 中的代码如下所示:
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[alertVC.view setTintColor:[UIColor copperColor]];
UIAlertAction* notifyViaPush = [UIAlertAction
actionWithTitle:@"Send Alert to my phone"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alertVC dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* notifyViaEmail = [UIAlertAction
actionWithTitle:@"Notify me by email"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alertVC dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* cancel = [UIAlertAction
actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action)
{
[alertVC dismissViewControllerAnimated:YES completion:nil];
}];
[alertVC addAction:notifyViaPush];
[alertVC addAction:notifyViaEmail];
[alertVC addAction:cancel];
[self presentViewController:alertVC animated:YES completion:nil];
如何使用 UIAlertController 对按钮进行分组并在操作和取消按钮之间留出一些空间?
【问题讨论】:
标签: ios ios8 uialertcontroller