我的應用程序中有一個圖像選擇器,可以打開用戶相冊(iOS),以便他們可以選擇圖像。我使用xamarin跨平臺,所以我有一個依賴服務導致這段代碼。之後我得到了所有正確的代碼,但問題在於圖像選擇器不顯示第一個或兩個,只在用戶刷新整個應用程序後纔開始工作。這是下面的代碼,我使用創建選擇器:ImagePicker不在Xamarin中顯示
imagePicker = new UIImagePickerController();
imagePicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.PhotoLibrary);
imagePicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
imagePicker.Canceled += Handle_Canceled;
//Show the picker
UIApplication.SharedApplication.KeyWindow.RootViewController.PresentModalViewController (imagePicker, true);
請注意,我已經試過NavigationController.PresentModalViewController但剛剛結束了一個空的錯誤。我也試過「PresentViewController」,但沒有幫助。另外,是否有任何不同的方式來顯示圖像選擇器?任何幫助將不勝感激!
我怎麼會顯示使用Xamarin媒體插件選擇器 –
就像我表現 - 的PickPhotoAsync()方法將顯示選擇器(在任何平臺上),並返回一個媒體文件對象您也可以使用它來使用TakePhotoAsync()拍攝相機的照片。示例和源代碼位於:https://github.com/jamesmontemagno/Xamarin.Plugins/tree/master/Media – Jason
非常感謝您太多了!它現在正在工作:) –