Hi,
I'm evaluating the IGGridView. One thing I've tried is to register a persistent gesture recognizer (RegisterGesture()) of type UITapGestureRecognizer to show the value in a UIPopover if a cell has been tapped.
But after tapping on a cell the app closes unexpectedly. Sometime an exception occurs of type NSInvalidArgumentExeption and no action handling code will be executed.
MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[__NSCFString target:]: unrecognized selector sent to instance 0x1d5c3630 at at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr) at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 at TestInfragistics.Application.Main (System.String[] args) [0x00008] in /Users/dmeier/Projects/TestInfragistics/TestInfragistics/Main.cs:16
As attached you can find my evaluating project (without the binaries because they are to big in size).
Hi Mark,
The error is b/c the UIPopoverController is being released while its being displayed. To avoid that, you need to make the UIPopover a field on your delegate:
UIPopoverController popover = null; [Export("HandleInput")] private void HandleInput(UITapGestureRecognizer gestureRecognizer) { var cell = gestureRecognizer.View as IGGridViewCell; var viewController = new UIViewController(); var textField = new UITextField(viewController.View.Bounds) { AutoresizingMask = ~UIViewAutoresizing.None, Text = cell.TextLabel.Text }; viewController.View.AddSubview(textField); popover = new UIPopoverController(viewController); popover.PresentFromRect(cell.Bounds, cell, UIPopoverArrowDirection.Any, true); }
-SteveZ
here is the stack trace:
{MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSGenericException Reason: -[UIPopoverController dealloc] reached while popover is still visible. at (wrapper managed-to-native) MonoTouch.Foundation.NSObject:monotouch_release_managed_ref (intptr) at MonoTouch.Foundation.NSObject.ReleaseManagedRef () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSObject.cs:92 at MonoTouch.Foundation.NSObject+NSObject_Disposer.Drain (MonoTouch.Foundation.NSObject ctx) [0x00062] in /Developer/MonoTouch/Source/maccore/src/Foundation/NSObject2.cs:708 at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr) at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 at TestInfragistics.Application.Main (System.String[] args) [0x00002] in c:\Users\Mark\Desktop\WORK\X\samples\TestInfragistics\TestInfragistics\Main.cs:18 NSGenericException: -[UIPopoverController dealloc] reached while popover is still visible. 0 CoreFoundation 0x045d702e __exceptionPreprocess + 206 1 libobjc.A.dylib 0x0480ce7e objc_exception_throw + 44 2 CoreFoundation 0x045d6deb +[NSException raise:format:] + 139 3 UIKit 0x03739bf2 -[UIPopoverController dealloc] + 86 4 libobjc.A.dylib 0x048209ff -[NSObject release] + 47 5 TestInfragistics 0x003e00bd monotouch_release_managed_ref + 173 6 ??? 0x12685a54 0x0 + 308828756 7 ??? 0x126859c4 0x0 + 308828612 8 ??? 0x126858a4 0x0 + 308828324 9 ??? 0x0d251da7 0x0 + 220536231 10 TestInfragistics 0x0028924b mono_jit_runtime_invoke + 843 11 TestInfragistics 0x0032784f mono_runtime_invoke + 127 12 TestInfragistics 0x003da248 monotouch_static_trampoline + 4216 13 libobjc.A.dylib 0x048205c8 +[NSObject performSelector:withObject:] + 70 14 Foundation 0x019a8765 __NSThreadPerformPerform + 327 15 CoreFoundation 0x0455af3f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 16 CoreFoundation 0x0455a96f __CFRunLoopDoSources0 + 239 17 CoreFoundation 0x0457d734 __CFRunLoopRun + 964 18 CoreFoundation 0x0457cf44 CFRunLoopRunSpecific + 276 19 CoreFoundation 0x0457ce1b CFRunLoopRunInMode + 123 20 GraphicsServices 0x05c6c7e3 GSEventRunModal + 88 21 GraphicsServices 0x05c6c668 GSEventRun + 104 22 UIKit 0x0326fffc UIApplicationMain + 1211 23 ??? 0x0e66e898 0x0 + 241625240 24 ??? 0x0e66c7b4 0x0 + 241616820 25 ??? 0x0e66c33c 0x0 + 241615676 26 ??? 0x0e66c4cf 0x0 + 241616079 27 TestInfragistics 0x0028924b mono_jit_runtime_invoke + 843 28 TestInfragistics 0x0032784f mono_runtime_invoke + 127 29 TestInfragistics 0x0032d361 mono_runtime_exec_main + 401 30 TestInfragistics 0x0032d124 mono_runtime_run_main + 628 31 TestInfragistics 0x001e7ced mono_jit_exec + 93 32 TestInfragistics 0x003c8760 main + 2784 33 libdyld.dylib 0x05160701 start + 1 34 ??? 0x00000003 0x0 + 3}
forgot to include stack trace
Steve,
I just took the sample attached to this thread TestInfragistics.zip and added your changes to it.
Crushing.....
Using vs.net 2013
Thanks
Mark
The way that sample demonstrates displaying a popover is still valid. Could you post your stack trace, as i'm at a loss for what the error could be. If you have a snippet of code as well, that could prove to be useful also.
Thanks,