【问题标题】:How to save image in custom location programatically in Xamarin IOS如何在 Xamarin IOS 中以编程方式将图像保存在自定义位置
【发布时间】:2017-10-26 09:47:53
【问题描述】:

我需要将图像保存在我的 ipod 设备 IOS 中的不同位置。默认情况下,它保存在相机胶卷中。我需要保存在其他位置。下面的代码是否有效? 如果有人工作,请将其转换为 c#

[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
        PHAssetChangeRequest *newAssetRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:image];
        newAssetRequest.creationDate = time;
        newAssetRequest.location = location;

        PHObjectPlaceholder *placeholderAsset = newAssetRequest.placeholderForCreatedAsset;

        PHAssetCollectionChangeRequest *addAssetRequest = [PHAssetCollectionChangeRequest changeRequestForAssetCollection:WHICH_ASSET_COLLECTION];
        addAssetRequest addAssets:@[placeholderAsset];

    } completionHandler:^(BOOL success, NSError *error) {
        NSLog(@"Success: %d", success);
    }];

提前致谢

【问题讨论】:

标签: c# ios xamarin xamarin.forms uiimage


【解决方案1】:

您可以使用System.IO.File.WriteAllBytes(String, Byte[]) 将图像保存到您作为参数设置的路径:

File.WriteAllBytes(PATH_TO_LOCATION, byteArray);

【讨论】:

  • 如何在 IOS 中获取路径位置。我不想将图像保存在相机胶卷中。如何在 iphone 中获取其他位置的路径?
猜你喜欢
  • 2018-02-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-09
  • 2013-03-07
  • 1970-01-01
  • 2016-02-22
  • 1970-01-01
相关资源
最近更新 更多