开发者

Crash when choosing from the iphone photo album using monotouch

My 开发者_C百科application crashes completely (fatal error), showing the entire stacktrace and "Error connecting stdout and stderr. The weird thing is though, if I do not shut down the iPhone simulator, and I go through the workflow on my app a second time, there is no crash.

I tried both PhotoLibrary and SavedPhotosAlbum;

When picker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary, everything works fine until it brings up the photo library. When you click the photo library to see the images inside, this is when the crash occurs.

When picker.SourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum, the album loads fine, and I can even select an image. After I select an image, I can edit the image, etc...Once I'm done and hit Choose. It crashes.

Again, after it crashes, I can go through the workflow and it gets through just fine.

This is very strange. Any ideas?

Thanks.


I had this exact same problem; it turns out the ImagePickerController object was being garbage collected, are you declaring the property inside of a method (e.g. a button touch event?). I found if I declared the property at the start of the class then it solved this problem. Code sample:

UIImagePickerController picker;

//snip

void HandlePhotoBtnTouchUpInside(object sender, EventArgs e)
{
    picker = new UIImagePickerController();
    ImagePickerDelegate imgDel = new ImagePickerDelegate();
    picker.Delegate = imgDel;

    picker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
    PresentModalViewController(imagePicker, true);
}

The ImagePickerDelegate Class is pretty simple, I've only overridden the FinishedPickingMedia method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜