Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
315
Prevent scrolling and set month in month view
posted

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!

Parents
No Data
Reply
  • 40030
    Verified Answer
    Offline posted

    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

Children