I need to prevent the user from scrolling in the month view. If I set UserInteractionEnabled to false (c#), it prevents scrolling, but then the MonthViewDayTapped doesn't fire. Do I need to mess with preventing swipe gestures on the calendar view? In addition, I need to be able to set the month that is shown in code. I see a few properties for the day view scroll location, but not for the month view. To give you the whole picture, above the calendar, I have "Previous", "Current", and "Next" in a UISegmentedControl, so that is the only way I want users to be able to change what is shown in the calendar. Thanks!
Hi Michael,
Changing the date is pretty simple. The IGCalendarView has a Navigate method, that takes a NSDate/DateTime, and the displayType. So you'd set it to a date that has the month/year you want displayed, and use the IGCalendarViewDisplayTypeMonth enumeration option.
I don't have a good solution for you on disabling the scrolling, as we don't expose access to the scrollView and the scrollView's delegate is being handled internally.
However, you could potentially do something like this:
Obj-C
UIView* monthView = [_cal valueForKey:@"_monthView"]; UIScrollView* scrollView = [monthView valueForKey:@"scrollView"];
UIPanGestureRecognizer* gesture = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(pan:)]; [scrollView addGestureRecognizer:gesture];
C#:
UIView monthView = (UIView)_calendarV.ValueForKey (new NSString("_monthView")); UIScrollView scrollView = (UIScrollView)monthView.ValueForKey (new NSString("scrollView")); UIPanGestureRecognizer gesture = new UIPanGestureRecognizer(this, new MonoTouch.ObjCRuntime.Selector("pan:")); scrollView.AddGestureRecognizer(gesture);
The implementation of your pan gesture listener can be empty.
-SteveZ
Somehow I completely glossed over the Navigate method. :) That all works great though. Thanks for the fast response!
For others, I did have to add an implementation for the pan gesture, with an export (I changed "pan:" to "panListener" as well):
[Export("panListener")] protected void OnCalendarPan(UIGestureRecognizer sender) { }
Just a quick note for others... you need the colon in the Export attribute (as Steve had in his) or your build server may complain:
[Export("panListener:")]