Подтвердить что ты не робот

Правильно представлять UIAlertController из MSMessagesAppViewController

Я пытаюсь выяснить, как отобразить UIAlertController со стилем UIAlertControllerStyleActionSheet в моем расширении приложения iMessage.

Проблема заключается в том, что лист действий появляется под текстовым полем исходного текста 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];

введите описание изображения здесь

4b9b3361

Ответ 1

Другое обходное решение:

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

Ответ 2

Вот обходной путь. Возможно, добавьте немного анимации, чтобы сделать ее гладкой.

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

Ответ 3

согласно this, вы можете запросить полноэкранное представление:

[self requestPresentationStyle:MSMessagesAppPresentationStyleExpanded];

перед кодом:

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