简体   繁体   中英

Photo picker shows on one second then disappears

I have an iOS application written in Xamarin. It is built to target iOS 7.1. with SDK 8. My code looks like following:

var dialog = DialogHelper.ShowProgress(View, "Uploading");
picker.PickPhotoAsync().ContinueWith(t =>
{
  if (t.IsCanceled || t.IsFaulted)
    {
      AppDelegate.FileUploadController.IsWorking = false;
      dialog.Dismiss();
      return;
    }
  MediaFile file = t.Result;
  string filePath = file.Path;
  UploadHelper.UploadFile(filePath, _folderId, temp, dialog);

}, TaskScheduler.FromCurrentSynchronizationContext());

This works great on iOS 7 (both simulator and device) but on iOS 8 photos are shown in one second, than loading screen is shown.

What am I doing wrong? I can't find any useful information googling it.

In case someone else will need this, https://components.xamarin.com/gettingstarted/xamarin.mobile says:

Showing a MediaPicker in response to a UIActionSheet.Clicked event will cause unexpected behavior on iOS 8. Apps should be updated to conditionally use an UIAlertController with a style of UIAlertControllerStyle.ActionSheet.

So I edited my code to use UIAlertController if device is on iOS 8.

And it works.

I had the same issue, i just changed the event clicked to event dismissed for the UIActionSheet. EJ.

           actionsheet.Dismissed+= delegate(object sender, UIButtonEventArgs b) {
           if(b.ButtonIndex==0){
                useCamera();
            }
            else if(b.ButtonIndex==1){
                useGallery();
            }

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM