gpt4 book ai didi

ipad - 更改 iOS8 中的操作表弹出箭头

转载 作者:行者123 更新时间:2023-12-03 02:03:56 27 4
gpt4 key购买 nike

我正在使用 UIAlertController 。但在装有 iOS 8 的 iPad 上,actionSheet 显示带有弹出箭头。有什么想法可以隐藏该箭头吗?

这是我的代码:

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"this is alert controller" message:@"yeah" preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction *cancelAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel action")
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action)
{
NSLog(@"Cancel action");
}];

UIAlertAction *okAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"OK", @"OK action")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
NSLog(@"OK action");
}];

UIAlertAction *deleteAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"Delete", @"Delete action")
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *action) {
NSLog(@"Delete action");
}];

[alertController addAction:cancelAction];
[alertController addAction:okAction];
[alertController addAction:deleteAction];

UIPopoverPresentationController *popover = alertController.popoverPresentationController;
if (popover) {
popover.sourceView = self.view;
popover.sourceRect = self.view.bounds;
popover.permittedArrowDirections = UIPopoverArrowDirectionUnknown;
}
[self presentViewController:alertController animated:YES completion:nil];

最佳答案

解决方案:
使用下面的行从操作表中删除箭头

[yourAlertController.popoverPresentationController setPermittedArrowDirections:0];


示例

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Test Action Sheet" message:@"Message" preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction *cancelAction = [UIAlertAction
actionWithTitle:@"Cancel"
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *action)
{
NSLog(@"Cancel action");
}];

UIAlertAction *okAction = [UIAlertAction
actionWithTitle:@"Ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
NSLog(@"OK action");
}];
UIAlertAction *otherAction = [UIAlertAction
actionWithTitle:@"Other"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
NSLog(@"Otheraction");
}];

[alertController addAction:okAction];
[alertController addAction:otherAction];
[alertController addAction:cancelAction];


// Remove arrow from action sheet.
[alertController.popoverPresentationController setPermittedArrowDirections:0];

//For set action sheet to middle of view.
alertController.popoverPresentationController.sourceView = self.view;
alertController.popoverPresentationController.sourceRect = self.view.bounds;

[self presentViewController:alertController animated:YES completion:nil];

输出

enter image description here

关于ipad - 更改 iOS8 中的操作表弹出箭头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25882133/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com