gpt4 book ai didi

ios - 带有 xam.Plugin.Media 的 iOS 10 上的相机问题

转载 作者:行者123 更新时间:2023-11-29 00:40:36 24 4
gpt4 key购买 nike

我将 Xam.Plugin.Media(版本:2.3.0)与 Xamarin Forms for iOS 一起使用。它在 iOS-10 的 iPhone 上运行良好,但是当应用程序在 iOS-10 的 iPad 上运行时,相同的代码将我从应用程序中踢出。

早些时候,在 iOS-9 上,它在 iphone 和 ipad 上都运行良好。我期待您的回复。谢谢

using Plugin.Media;
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms;
namespace LearnForms.Pages
{
public class pgOpenCamera: ContentPage
{
private Image image1 { get; set; }
public StackLayout StkPage { get; set; }
public Button btnOpenCamera { get; set; }

public pgOpenCamera()
{
btnOpenCamera = new Button()
{
Text ="Open Camera!"
};
btnOpenCamera.Clicked += BtnOpenCamera_Clicked;
image1 = new Image();
StkPage = new StackLayout()
{
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
Padding = new Thickness(20),
Children = {btnOpenCamera, image1}
};
Content = StkPage;
}

private async void BtnOpenCamera_Clicked(object sender, EventArgs e)
{
if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
{
DisplayAlert("No Camera", ":( No camera available.", "OK");
return;
}
var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
Directory = "Sample",
Name = "test.jpg"
});
if (file == null)
return;
DisplayAlert("File Location", file.Path, "OK");
image1.Source = ImageSource.FromStream(() =>
{
var stream = file.GetStream();
file.Dispose();
return stream;
});
}
}
}

卡齐...

最佳答案

取自here :

Your app is required to have keys for NSCameraUsageDescription and NSPhotoLibraryUsageDescription in order to access the device's camera and photo library. The string that you provide for each of these keys will be displayed to the user when they are prompted to provide permission to access these device features.

所以我建议你将这些添加到你的 Info.plist 中。好像是变了since iOS 10 .

关于ios - 带有 xam.Plugin.Media 的 iOS 10 上的相机问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39618152/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com