gpt4 book ai didi

ios - 从 MSMessagesAppViewController 正确呈现 UIAlertController

转载 作者:行者123 更新时间:2023-11-30 12:58:17 25 4
gpt4 key购买 nike

我正在尝试弄清楚如何在我的 iMessage 应用扩展中显示样式为 UIAlertControllerStyleActionSheetUIAlertController

问题是,调用时显示的操作表出现在 native iMessage 文本字段下方:

[self.view.window.rootViewControllerpresentViewController:actionSheetControlleranimated:YES完成:NULL];

我该如何解决这个问题?

代码:

UIAlertController *actionSheetController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Clear", nil) message:nil preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction *clear = [UIAlertAction actionWithTitle:NSLocalizedString(@"Clear", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action)
{
[self clear];
}];

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

[actionSheetController addAction:clear];
[actionSheetController addAction:cancel];

[self.view.window.rootViewController presentViewController:actionSheetController animated:YES completion:NULL];

enter image description here

最佳答案

这里有一个解决方法。也许添加一点动画以使其平滑。

[self.view.window.rootViewController presentViewController:actionSheetController animated:YES completion:^{
actionSheetController.view.frame = CGRectOffset(actionSheetController.view.frame, 0, -40);
}];

关于ios - 从 MSMessagesAppViewController 正确呈现 UIAlertController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40160881/

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