Kenin
Kenin

Reputation: 420

UIPopoverController And UIImagePickerController problems with Monotouch

I use to develop an application MonoTouch Iphone, but I have a problem using UIPopoverController. I can not open the page to select the photo. I use the class of camera.cs TweetStation.

Here's the code:

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);
        }

Thanks for your help.

Upvotes: 1

Views: 1181

Answers (1)

holmes
holmes

Reputation: 1341

I have a few suggestions. First make the UIPopoverController a member variable so that it does not get collected.

Second I called ContentSizeForViewInPopover on the picker.

picker.ContentSizeForViewInPopover = new SizeF(this.View.Frame.Width,this.View.Frame.Height); 

Finally I use a 0x0 rectangle in the upper left of the screen for the PresentFromRect call.

_popover.PresentFromRect(new RectangleF (0,0,0,0),this.View,UIPopoverArrowDirection.Up,true);

Upvotes: 1

Related Questions