Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 启动带有图像的safari或保存到相机卷问题_Ios_Xamarin.ios - Fatal编程技术网

Ios 启动带有图像的safari或保存到相机卷问题

Ios 启动带有图像的safari或保存到相机卷问题,ios,xamarin.ios,Ios,Xamarin.ios,我已从web服务下载了一张图像,需要在safari中打开该图像或将其保存到相机卷中。我尝试在Safari中打开图像,但Safari没有打开 var safari = UIApplication.SharedApplication; var uri = new NSUrl(path); // where the image is saved to safari.OpenUrl(uri); 这会编译,但Safari不会启动 我保存到照相胶卷的代码是 PHPhotoLibrary.SharedPho

我已从web服务下载了一张图像,需要在safari中打开该图像或将其保存到相机卷中。我尝试在Safari中打开图像,但Safari没有打开

var safari = UIApplication.SharedApplication;
var uri = new NSUrl(path); // where the image is saved to
safari.OpenUrl(uri);
这会编译,但Safari不会启动

我保存到照相胶卷的代码是

PHPhotoLibrary.SharedPhotoLibrary.PerformChanges(() =>
{
      using (var pool3 = new NSAutoreleasePool())
      {                                     pool3.InvokeOnMainThread(delegate ()
           {                                                               PHAssetChangeRequest.FromImage((UIImage)UIImage.FromFile(path));
           });
      }
      }, (t, err) =>
      {
           if (!t)
           {
                 using (var pool1 = new NSAutoreleasePool())
                 {
                      pool1.InvokeOnMainThread(delegate () {
                           var alert = new UIAlertView("Error saving file", "An error has occured saving your photo to the camera roll", null, "OK");
                          alert.Show();
                          };
           }
           else
           {
                 using (var pool2 = new NSAutoreleasePool())
                 {
                       pool2.InvokeOnMainThread(delegate (){
                            var alert = new UIAlertView("Image saved", "Your image has been saved to the camera roll", null, "OK"); 
                            alert.Show();
                            });
                        };
                 }
         });
哪些崩溃和烧毁(已设置正确的权限)


我不明白为什么这两种方法都不起作用,因为它们似乎都是正确的。

你不能用safari打开本地路径,这在iOS上是不允许的(应用程序是沙盒的)因此,您需要使用远程URL或拥有自己的
UIWebView
WKWebView
SFSafariViewController
以类似safari的体验显示该图像。关于这个话题

另外,这里有一个很好的保存到相机辊照片,你可以做你自己的解决方案的基础上


希望这有帮助

您无法使用safari打开本地路径,这在iOS上是不允许的(应用程序是沙盒的),因此您需要使用远程URL或拥有自己的
UIWebView
WKWebView
SFSafariViewController
以类似safari的体验显示该图像。关于这个话题

另外,这里有一个很好的保存到相机辊照片,你可以做你自己的解决方案的基础上

希望这有帮助