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

本文关键字:转换 外观 不平衡 调用 结束 MediaPicker 开始 使用 | 更新日期: 2023-09-27 18:14:21

我一直有这个不平衡调用的常见问题。我认为这可能是因为在我结束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;
    }

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

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