Ответ 1
Другое обходное решение:
actionSheetController.view.transform = CGAffineTransform(translationX: 0, y: -40)
[self.view.window.rootViewController presentViewController:actionSheetController animated:YES completion:NULL];
Я пытаюсь выяснить, как отобразить 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];
Другое обходное решение:
actionSheetController.view.transform = CGAffineTransform(translationX: 0, y: -40)
[self.view.window.rootViewController presentViewController:actionSheetController animated:YES completion:NULL];
Вот обходной путь. Возможно, добавьте немного анимации, чтобы сделать ее гладкой.
[self.view.window.rootViewController presentViewController:actionSheetController animated:YES completion:^{
actionSheetController.view.frame = CGRectOffset(actionSheetController.view.frame, 0, -40);
}];
согласно this, вы можете запросить полноэкранное представление:
[self requestPresentationStyle:MSMessagesAppPresentationStyleExpanded];
перед кодом:
[self.view.window.rootViewController presentViewController:actionSheetController animated:YES completion:NULL];