Я создаю DocumentInteractionViewController для предварительного просмотра файлов, когда я нажимаю на значок «Поделиться», затем на опцию «Сохранить в файлы» после этого. Если я сохраняю или отменяю, это выдает эту ошибку на устройствах размера iPhone 7.
Objective-C exception thrown. Name: UIApplicationInvalidInterfaceOrientation Reason: preferredInterfaceOrientationForPresentation 'unknown' must match a supported interface orientation: 'portrait, landscapeLeft, landscapeRight, portraitUpsideDown'!
Отлично работает в ipad или iphone Xr.
public class DocumentInteractionViewController
{
private UIDocumentInteractionController _documentInteractionController;
public DocumentInteractionViewController(string url)
{
if (!url.Contains(AppConstant.Protocols.File))
{
url = $"{AppConstant.Protocols.File}{url}";
}
_documentInteractionController = new UIDocumentInteractionController
{
Url = new NSUrl(Uri.EscapeUriString(url))
};
}
public void PresnetPreview(UIViewController viewController)
{
viewController = viewController.NavigationController ?? viewController;
viewController.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext;
_documentInteractionController.RectangleForPreview = (e) => viewController.View.Frame;
_documentInteractionController.ViewControllerForPreview = (e) => viewController;
if (!_documentInteractionController.PresentPreview(true))
{
PresentOptionsMenu(viewController.View);
}
}
public void PresentOptionsMenu(UIView view)
{
_documentInteractionController.PresentOptionsMenu(view.Frame, view, true);
}
}