Ipad UIPopoverController和UIImagePickerController存在单触问题

Ipad UIPopoverController和UIImagePickerController存在单触问题,ipad,xamarin.ios,uiimagepickercontroller,uipopovercontroller,Ipad,Xamarin.ios,Uiimagepickercontroller,Uipopovercontroller,我曾经开发过一款应用程序MonoTouch Iphone,但我在使用UIPopoverController时遇到了一个问题。我无法打开页面选择照片。 我使用camera.cs TweetStation类 代码如下: public static void SelectPicture (UIViewController parent, Action<NSDictionary> callback) { if(OzytisUtils.isIpad()){

我曾经开发过一款应用程序MonoTouch Iphone,但我在使用UIPopoverController时遇到了一个问题。我无法打开页面选择照片。 我使用camera.cs TweetStation类

代码如下:

public static void SelectPicture (UIViewController parent, Action<NSDictionary> callback)
    {

        if(OzytisUtils.isIpad()){

            picker = new UIImagePickerController();
            UIPopoverController popover = new UIPopoverController(picker);
            picker.Delegate = new CameraDelegate();
            picker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
            popover.SetPopoverContentSize(new SizeF(parent.View.Frame.Width,parent.View.Frame.Height),true);
            if(popover.PopoverVisible){
                popover.Dismiss(true);
                picker.Dispose();
                popover.Dispose();
            }else{
                popover.PresentFromRect(parent.View.Frame,parent.View,UIPopoverArrowDirection.Right,true);

            }

        }else{
            Init ();
            picker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
            _callback = callback;           
            parent.PresentModalViewController (picker, true);
        }
publicstaticvoidselectpicture(UIViewController父级,动作回调)
{
if(OzytisUtils.isIpad()){
picker=新的UIImagePickerController();
UIPOPCOVERCONTROLLER POPOOVER=新UIPOPCOVERCONTROLLER(选择器);
picker.Delegate=新的CameraDelegate();
picker.SourceType=UIImagePickerController源类型.PhotoLibrary;
SetPopoverContentSize(新的SizeF(parent.View.Frame.Width,parent.View.Frame.Height),true);
if(popover.PopoverVisible){
popover.discover(true);
picker.Dispose();
popover.Dispose();
}否则{
PresentFromRect(parent.View.Frame、parent.View、UIPopOverErrorDirection.Right、true);
}
}否则{
Init();
picker.SourceType=UIImagePickerController源类型.PhotoLibrary;
_回调=回调;
parent.PresentModalViewController(选择器,true);
}

谢谢您的帮助。

我有一些建议。首先将UIPopoverController设置为成员变量,这样它就不会被收集

第二,我在选择器上调用ContentSizeForViewInPopover

picker.contentsizeforviewinpover=newsizef(this.View.Frame.Width,this.View.Frame.Height);
最后,我使用屏幕左上角的一个0x0矩形来调用PresentFromRect

\u popover.PresentFromRect(新矩形f(0,0,0,0),this.View,UIPopoverArrowDirection.Up,true);

我有一些建议。首先将UIPopoverController设置为成员变量,这样它就不会被收集

第二,我在选择器上调用ContentSizeForViewInPopover

picker.contentsizeforviewinpover=newsizef(this.View.Frame.Width,this.View.Frame.Height);
最后,我使用屏幕左上角的一个0x0矩形来调用PresentFromRect

\u popover.PresentFromRect(新矩形f(0,0,0,0),this.View,UIPopoverArrowDirection.Up,true);