From 4e69d62f107ea093d983f7c0b550ac55f5afd007 Mon Sep 17 00:00:00 2001 From: Danmei Chen Date: Wed, 27 Nov 2019 14:31:37 +0100 Subject: [PATCH] fix send documents from chatroom not works in ipad --- Classes/ImagePickerView.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Classes/ImagePickerView.m b/Classes/ImagePickerView.m index 915eef6b2..a69ae4dde 100644 --- a/Classes/ImagePickerView.m +++ b/Classes/ImagePickerView.m @@ -396,7 +396,17 @@ static UICompositeViewDescription *compositeDescription = nil; +(void) pickDocumentForDelegate:(id)documentMenuDelegate { UIDocumentMenuViewController *documentProviderMenu = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:SUPPORTED_EXTENTIONS inMode:UIDocumentPickerModeImport]; documentProviderMenu.delegate = documentMenuDelegate; - [PhoneMainView.instance presentViewController:documentProviderMenu animated:YES completion:nil]; + if (IPAD) { + /* On iPad the activity view controller will be displayed as a popover using the new UIPopoverPresentationController, it requires that you specify an anchor point for the presentation of the popover using one of the three following properties: barButtonItem, sourceView, sourceRect */ + ChatConversationView *chatView = VIEW(ChatConversationView); + documentProviderMenu.popoverPresentationController.sourceView = chatView.view; + CGRect frame = documentProviderMenu.popoverPresentationController.sourceRect; + CGRect topBarFrame = chatView.topBar.frame; + documentProviderMenu.popoverPresentationController.sourceRect = CGRectMake(topBarFrame.origin.x + topBarFrame.size.width/2, topBarFrame.origin.y + topBarFrame.size.height, frame.size.width, frame.size.height); + } + dispatch_async(dispatch_get_main_queue(), ^ { + [PhoneMainView.instance presentViewController:documentProviderMenu animated:YES completion:nil]; + }); } @end