Open images and files in Xamarin iOS using native apps

Hakob Hovhannisyan 21 Reputation points
2022-09-15T11:46:12.66+00:00

Hello, please help me to find the solution, how can I open an image or video, pdf, or docs with the native app on the IOS from my files list using Xamarin Forms IOS?

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,366 questions
{count} votes

Accepted answer
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 33,091 Reputation points Microsoft Vendor
    2022-09-16T05:38:23.85+00:00

    Hello @Hakob Hovhannisyan ,

    You can use UIDocumentInteractionController in Xamarin.iOS, please refer to the following code:

      partial void ClicktoOpenInOtherAPP(UIButton sender)// a button action, click to present menu  
                {  
                    string filename = NSBundle.MainBundle.PathForResource("test","png");// test.png is added in my project, its build action is BundleResource  
                    UIDocumentInteractionController documentInteractionController = UIDocumentInteractionController.FromUrl(new NSUrl(filename, false));//you can replace this file by your other file path  
                   documentInteractionController.PresentOpenInMenu(this.View.Bounds, this.View, true);// present  
          
                }  
    

    Best Regards,
    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.