从MSMessagesAppViewController正确呈现UIAlertController

编程入门 行业动态 更新时间:2024-10-28 11:29:20
本文介绍了从MSMessagesAppViewController正确呈现UIAlertController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I'm trying to figure out how to display a UIAlertController with a style of UIAlertControllerStyleActionSheet within my iMessage app extension.

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

The problem is, the action sheet appears below the native iMessage text field when presented when calling:

[self.view.window.rootViewController presentViewController:actionSheetController animated:YES completion: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];

推荐答案

另一种解决方法:

actionSheetController.view.transform = CGAffineTransform(translationX: 0, y: -40) [self.view.window.rootViewController presentViewController:actionSheetController animated:YES completion:NULL];

更多推荐

从MSMessagesAppViewController正确呈现UIAlertController

本文发布于:2023-11-27 19:28:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639308.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:正确   MSMessagesAppViewController   UIAlertController

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!