正确地从MSMessagesAppViewController呈现一个UIAlertController

我想弄清楚如何在我的iMessage应用程序扩展中显示一个UIAlertController样式的UIAlertControllerStyleActionSheet

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

[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]; 

这是一个解决方法。 也许添加一些animation,使其平滑。

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

据此,您可以通过以下方式请求全屏演示:

 [self requestPresentationStyle:MSMessagesAppPresentationStyleExpanded]; 

在你的代码之前:

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