我试图弄清楚如何在我的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];


ios - 从MSMessagesAppViewController正确呈现UIAlertController-LMLPHP

最佳答案

这是一种解决方法。也许添加一些动画使其平滑。

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

10-08 12:25