如何在Xamarin.UITesting中与摄影机卷交互?
我一直在尝试在Xamarin.iOS中点击相机卷,当它在我的应用程序中打开时使用Xamarin.ui进行测试,但由于它是操作系统的一部分,我无法使用点击功能选择相机卷,然后选择图像。使用app.Repl(),它的显示方式如下:如何在Xamarin.UITesting中与摄影机卷交互?,xamarin,xamarin.ios,visual-studio-app-center,xamarin.uitest,Xamarin,Xamarin.ios,Visual Studio App Center,Xamarin.uitest,我一直在尝试在Xamarin.iOS中点击相机卷,当它在我的应用程序中打开时使用Xamarin.ui进行测试,但由于它是操作系统的一部分,我无法使用点击功能选择相机卷,然后选择图像。使用app.Repl(),它的显示方式如下: [CalabashRootView] [UIWindow > ... > UILayoutContainerView] [U
[CalabashRootView]
[UIWindow > ... > UILayoutContainerView]
[UINavigationTransitionView > ... > _UISizeTrackingView]
[_UIRemoteView] id: "RemoteViewBridge"
[UINavigationBar] id: "Photos"
[_UIBarBackground]
[UIImageView]
[UIVisualEffectView]
[_UIVisualEffectBackdropView]
[_UIVisualEffectSubview]
[_UINavigationBarContentView]
[_UIButtonBarStackView]
[_UIButtonBarButton] label: "Cancel"
[_UIModernBarButton] label: "Cancel"
[UIButtonLabel] label: "Cancel", text: "Cancel"
[UILabel] label: "Photos", text: "Photos"
[UILabel] label: "Photos", text: "Photos"
[_UIButtonBarButton] label: "Cancel"
[_UIModernBarButton] label: "Cancel"
[UIButtonLabel] label: "Cancel", text: "Cancel"
[UIWindow > UILayoutContainerView]
[UINavigationTransitionView > ... > UITableView]
[WelcomeScreenCustomCell]
[UITableViewCellContentView]
[UIView]
我试图通过后门将图像推入照片选择过程,但似乎无法正常工作(这是我的AppDelegate):
有人有过这样的经历吗?有没有办法只选择一张图片?你可以使用Nuget的插件MediaPlugin 不要忘记在indo.plist中添加NSCameraUsageDescription和NSPhotoLibraryUsageDescription,以便访问设备的相机和照片/视频库
<key>NSCameraUsageDescription</key>
<string>This app needs access to the camera to take photos.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs access to photos.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app needs access to microphone.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>This app needs access to the photo gallery.</string>
<key>NSCameraUsageDescription</key>
<string>This app needs access to the camera to take photos.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs access to photos.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app needs access to microphone.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>This app needs access to the photo gallery.</string>
async void TakePhoto()
{
await CrossMedia.Current.Initialize();
if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
{
// No camera available.
return;
}
var file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
{
Directory = "Sample",
Name = "test.jpg"
});
if (file == null)
return;
var ImagePath = file.Path;
//... do something you want
}