As the exception said, you can only use the UIImagePickerController from a popover. That means it must be directly in a popover. You are trying to present it as a modal view controller, but you can't do that. Do this instead:
popover = new UIPopoverController(picker);
popover.PresentFromRect(...);
Sent from my iPad
On Jul 28, 2012, at 5:59 AM, "proindigo" <[email protected]> wrote:
> Well I have made some modifications.
>
> I am trying to open a popup on clicking the 'Take Photograph' button. In
> that popup I am supposed to load the images that have been saved from
> internet. Here is the code I am using to open popup.
>
> partial void TakeSpacePhoto (MonoTouch.UIKit.UIButton sender)
> {
> var camera=UIImagePickerControllerSourceType.Camera;
> if(UIImagePickerController.IsSourceTypeAvailable (camera))
> {
> UIImagePickerController picker=new UIImagePickerController();
> picker.SourceType=camera;
> picker.Delegate=new StillImagePickerDelegate(new PhotoPicker());
> this.PresentModalViewController (picker, true);
>
> }
> else
> {
> popover=new UIPopoverController(new PhotoPicker());
> popover.PopoverContentSize=new SizeF(400f, 600f);
> popover.PresentFromRect(btnTakePhoto.Frame, this.View,
> UIPopoverArrowDirection.Any, true);
> }
> }
>
> Here PhotoPicker is an empty Ipad View Controller with no elements int.
> And in the ViewDidLoad event of this form I am using the following code:
>
> public override void ViewDidLoad ()
> {
> base.ViewDidLoad ();
> if (
> UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.SavedPhotosAlbum)
> )
> {
> UIImagePickerController picker=new UIImagePickerController();
> picker = new UIImagePickerController();
> picker.Delegate = new ImageGalleryPickerDelegate(this);
> picker.SourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum;
> this.PresentModalViewController(picker, true);
>
> }
> // Perform any additional setup after loading the view, typically from a
> nib.
> }
>
>
> Here ImageGalleryPickerDelegate is the same class that I posted in my
> previous post. The situation is that when the popup opens it is completely
> empty. There are no images in it. Why aren't the images bring loaded? I've
> tried both SavedPhotoAlbums and PhotoGallery as source types, but no
> success.
>
> Please help me somebody. I am hopelessly stuck!!
>
> Many Thanks.
>
>
>
> --
> View this message in context: http://monotouch.2284126.n4.nabble.com/Take-Pictures-with-IPHone-Camera-tp4656124p4656217.html
> Sent from the MonoTouch mailing list archive at Nabble.com.
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch
_______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
