使用MediaPicker的不平衡调用开始/结束外观转换

时间:2014-07-22 23:53:21

标签: c# ios iphone xamarin.ios xamarin

我一直有这个不平衡电话的常见问题。我想这可能是因为在我结束我的MediaPicker后,我改为新视图。但是我并不积极。这是代码。上一篇文章中有人提到当您尝试加载到视图时会发生这种情况。 MediaPicker会导致这种情况吗?

int votingTime;
    bool perform = false;

    MediaPicker videoPicker;
    MediaFile media;
    //readonly TaskScheduler uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();

    public LengthViewController (IntPtr handle) : base (handle)
    {
    }

    public override void DidReceiveMemoryWarning ()
    {
        // Releases the view if it doesn't have a superview.
        base.DidReceiveMemoryWarning ();

        // Release any cached data, images, etc that aren't in use.
    }

    public override void ViewDidLoad ()
    {
        base.ViewDidLoad ();
        //Make the navigation bar not hidden
        NavigationController.SetNavigationBarHidden (false, true);

        //Create a button on NavBar on the right side (Logout)
        this.NavigationItem.SetRightBarButtonItem(
            new UIBarButtonItem(UIBarButtonSystemItem.Action, (sender,args) => {
                //Logout of Facebook
                FBSession.ActiveSession.CloseAndClearTokenInformation();
                //Return to Login page
                NavigationController.PopToRootViewController(true);
            })
            , true);
        //Hides the back button no point in going back to the login page
        //Instead hit the logout to go back to login page
        this.NavigationItem.SetHidesBackButton (true, true);

        //Populate the two pickers

        PickerDataModel voting = new PickerDataModel ();

        voting.Items.Add ("30 Minutes");
        voting.Items.Add ("1 Hour");
        voting.Items.Add ("2 Hours");

        pv_voting.Model = voting;

        btn_length.TouchUpInside += async delegate {
            //The selected item in the picker reduce it down to just a number
            votingTime = Convert.ToInt32(Regex.Replace(voting.SelectedItem, @"\D", ""));

            videoPicker = new MediaPicker ();

            //Let the user select the video they wish to upload.
            try
            {
                // Bring up the videoPickerUI
                media = await videoPicker.PickVideoAsync();
                //Move to next screen

                PerformSegue("seg_toVideo", this);
            }
            catch( TaskCanceledException)
            {
                //If they cancelled the task don't perform segue
                perform = false;
            }
        };
    }

    public override void PrepareForSegue (UIStoryboardSegue segue, NSObject sender)
    {
        base.PrepareForSegue (segue, sender);

        VideoViewController vc = (VideoViewController)segue.DestinationViewController;
        //Send the mediafile we created
        vc.Voting = votingTime;
        vc.file = media;
    }

1 个答案:

答案 0 :(得分:0)

这主要发生在你试图呈现一个viewCOntroller而其他人仍然被解雇时,如果是这样的话,你应该在这两个操作之间加一个延迟......这可能会解决问题