Bug 4792 - QLPreviewController Crashing when Presented
Summary: QLPreviewController Crashing when Presented
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.2
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
: 4906 ()
Depends on:
Reported: 2012-05-01 07:23 UTC by Phil
Modified: 2012-05-07 03:35 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Solution showing Previewer Issue (685.82 KB, application/zip)
2012-05-01 07:39 UTC, Phil

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Phil 2012-05-01 07:23:40 UTC
I have recently updated to Lion, and am running monotouch v 5.2.11

I have just noticed that if you subscribe to the DidDismiss or the WillDismiss events then present the view using PresentViewController or PresentModalViewController we get an exception. 

If animated = true the error happens on show, if false the the error is on dismiss.

This has only come up in a recent build. the code i am running has not changed for a good while.

The Exception is:

Message : Exception of type 'System.Exception' was thrown.
CallStack :

  at MonoTouch.QuickLook.QLPreviewController+_QLPreviewControllerDelegate.FrameForPreviewItem (MonoTouch.QuickLook.QLPreviewItem item, MonoTouch.UIKit.UIView view) [0x00019] in /Developer/MonoTouch/Source/monotouch/src/QuickLook/QLPreviewController.g.cs:264 
  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr_bool_IntPtr (intptr,intptr,intptr,bool,intptr)
  at MonoTouch.UIKit.UIViewController.PresentViewController (MonoTouch.UIKit.UIViewController viewControllerToPresent, Boolean animated, MonoTouch.Foundation.NSAction completionHandler) [0x00064] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIViewController.g.cs:481 
  at PreviewerTest.PreviewerTestViewController.ShowPreviewer () [0x0002f] in /Users/philipjames/Projects/PreviewerTest/PreviewerTest/PreviewerTestViewController.cs:71
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-05-01 07:30:06 UTC
This exception means that there is no handler for the FrameForPreviewItem event. Do you have such a handler in your code? Maybe you can provide a test case we can try out?
Comment 2 Phil 2012-05-01 07:39:04 UTC
Created attachment 1784 [details]
Solution showing Previewer Issue

This is a simplified version, but is basically what i call in my project to create this issue
Comment 3 Rolf Bjarne Kvinge [MSFT] 2012-05-01 07:40:09 UTC
The exception message has been improved now, in the next beta release (5.3.4) we'll now say: "No event handler has been added to the FrameForPreviewItem event.""
Comment 4 Rolf Bjarne Kvinge [MSFT] 2012-05-01 08:10:05 UTC
This has now been fixed (monotouch master 0e24930ad4d), an event handler will not be required for this event starting with MonoTouch 5.3.4.

In the meantime you can add an event handler like this as a workaround:

preview.FrameForPreviewItem += (QLPreviewItem sender, UIView view) => RectangleF.Empty;
Comment 5 Rolf Bjarne Kvinge [MSFT] 2012-05-07 03:35:14 UTC
*** Bug 4906 has been marked as a duplicate of this bug. ***