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 Danny,
Thanks for the sample!
Basically, Xamarin.iOS has a couple ways of creating gestures, and the way you're using unfortunately isn't compatible for being called by the obj-c runtime. However, its actually quite simple to make that adjustment.
Here's a link that shows they way you need to do it: http://dan.clarke.name/2012/08/using-uigesturerecognizer-in-monotouch/
Also, i've modified your code to this:
public override void InitializeCell(IGGridView gridView, IGGridViewCell cell) { var path = gridView.ResolvePathForCell(cell); if (path.IsFixed == IGGridViewFixedColumnDirection.IGGridViewFixedColumnDirectionNone) { var tapGesture = new UITapGestureRecognizer(this, new MonoTouch.ObjCRuntime.Selector("HandleInput")); //var tapGesture = new UITapGestureRecognizer(HandleInput) { NumberOfTapsRequired = 1}; cell.RegisterGestures(new[] { tapGesture }); } } [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); var popover = new UIPopoverController(viewController); popover.PresentFromRect(cell.Bounds, cell, UIPopoverArrowDirection.Any, true); }
Hope this helps. Don't hesitate if you have any more questions.
-SteveZ
Steve,
I tried to handle cell input the way you suggest but it is crushing application. Once popover comes up a short delay like half seconds and the whole app is crushing.
Is it still the right way to display popovers on a cell tap?
Thanks
Mark
Hi 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,
I just took the sample attached to this thread TestInfragistics.zip and added your changes to it.
Crushing.....
Using vs.net 2013
No problem.
My guess is that Xamarin must have gotten more strict in what they would accept.
-Steve
true,
checked all my code - never had a column before and all was good, weird.
Thank you very much
Hey Mark,
I think a colon is just missing.
Try this:
var tapGesture = new UITapGestureRecognizer(this, new MonoTouch.ObjCRuntime.Selector("HandleInput:"));
[Export("HandleInput:")]
hi steve,
today I discovered that the existing code using tapping doesnot work anymore. I tried attached sample and it gives me the same error during the load process of the program.
the selector 'HandleInput' indicates the method takes 0 parameters, while the managed method has 1 parameters.
was something changed in infragistics libraries? what do I need to update?
yes, thank you