UIAlertController的弹出窗口变形了 [英] UIAlertController's popover is deformed

查看:346
本文介绍了UIAlertController的弹出窗口变形了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用UIToolbar中的UIAlertController向用户提供一个选项列表,其中包含首选的操作表样式。呈现时,popover的箭头被切掉,其角落有两个不同的半径:

I'm presenting a list of options to the user using an UIAlertController from a UIToolbar with a preferred style of action sheet. When presented, the popover's arrow is cut off and its corners are rounded with two different radii:

我用来呈现它的代码直接来自文档,据我所知:

The code I'm using to present it is straight from the documentation, as far as I see it:

UIAlertController *alertController =
    [UIAlertController alertControllerWithTitle:@""
                                        message:@""
                                 preferredStyle:UIAlertControllerStyleActionSheet];
NSArray *actions = @[
    [UIAlertAction actionWithTitle:@"Take a Photo"
                             style:UIAlertActionStyleDefault
                           handler:^(UIAlertAction *action) {}],
    [UIAlertAction actionWithTitle:@"Choose from Album"
                             style:UIAlertActionStyleDefault
                           handler:^(UIAlertAction *action) {}],
    [UIAlertAction actionWithTitle:@"Cancel"
                             style:UIAlertActionStyleCancel
                           handler:^(UIAlertAction *action) {}]
];
for (UIAlertAction *action in actions) {
    [alertController addAction:action];
}

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    alertController.modalPresentationStyle = UIModalPresentationPopover;
    alertController.popoverPresentationController.barButtonItem = myBarButtonItem;
}
[self presentViewController:alertController animated:YES completion:nil];

这是一个已知错误吗?我在iOS 8.2和iOS 8.1和8.2上的模拟器上尝试过物理iPad。

Is this a known bug? I've tried a physical iPad on iOS 8.2 and the simulator on iOS 8.1 and 8.2.

推荐答案

尝试显式设置allowedArrowDirections。

Try explicitly setting the permittedArrowDirections.

例如在Swift中:

actionSheet.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.Down;

这篇关于UIAlertController的弹出窗口变形了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆