Im currently working on a feature to drag and drop items from a UITableView into a IGCalendarView.
Once i end the drag gesture i need to figure out what day the item was dropped on in my month view calendar. When i end the gesture i can work out the view that the item is dropped on but from there i need to associate that view with a calendar day.
Any help would be appreciated, thanks.
Hi Matt,
We don't currently offer any public API's to do this. However, it's still actually possible.
Here is the code to do it:
CGPoint point = [gesture locationInView:_cal];
UIView* multiMonthView = [_cal valueForKey:@"_monthView"];
id dateInfo = objc_msgSend(multiMonthView, @selector(resolveDateForPoint:),point);
if(dateInfo != nil)
{
NSDate* date = objc_msgSend(dateInfo, @selector(resolveActualDateObject:), _cal);
NSLog(@"%@", date);
}
Hope this helps!
-SteveZ
Hi Stephen,
Thanks for the quick reply!
How would i write this in c# using Xamarin?
Thanks,
Matt
Hey Matt,
In c# it would look something like:
UIView multiMonthView = (UIView)calView.ValueForKey (new NSString("_monthView")); PointF point = gesture.LocationInView(calView); IntPtr dateInfoPtr = Messaging.IntPtr_objc_msgSend_PointF(multiMonthView.Handle, new Selector(new NSString ("resolveDateForPoint:")).Handle,point); if(dateInfoPtr != IntPtr.Zero) { IntPtr datePtr = Messaging.IntPtr_objc_msgSend_IntPtr(dateInfoPtr, new Selector(new NSString ("resolveActualDateObject:")).Handle, calView.Handle); NSDate date = new NSDate(datePtr); }
Note, i added the following Using statement at the top of the file: using MonoTouch.ObjCRuntime;
Hope this helps,
Thanks, that did the trick!