Articles in this section
Category / Section

How to move to required time in Xamarin.iOS Schedule?

1 min read

In Xamarin Schedule You can move to required time while switching Schedule view by using MoveToTime support in CellTapped event which will be fired while tapping schedule cell. In CellTappedEventHandler, set required ScheduleView to be switched. Set MoveToDate property to schedule with required hour and date to be moved on tapping a date on month cell. Such that view moves to that particular date and time in day view. Time of the day can be positioned in center of the view while switching from month view to day view by setting current time to the date and subtracting the hours needed from the current time of the day. 

 

C#

 
          SFSchedule schedule = new SFSchedule();
          schedule.ScheduleView = SFScheduleView.SFScheduleViewMonth;
          schedule.CellTapped += Schedule_CellTapped;
          View.AddSubview(schedule);
           
         schedule.CellTapped += CellTappedEventHandler;
        
        void CellTappedEventHandler(object sender, CellTappedEventArgs e)
        {
            if (schedule.ScheduleView == SFScheduleView.SFScheduleViewMonth)
            {
                schedule.ScheduleView = SFScheduleView.SFScheduleViewDay;
                NSCalendar calendar = NSCalendar.CurrentCalendar;
                NSDate today = NSDate.Now;
                // Get the year, month, day from the date
                NSDateComponents dateComponents = calendar.Components(
                   NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day | NSCalendarUnit.Hour | NSCalendarUnit.Minute | NSCalendarUnit.Second, today);
                var numberOfSecondsPerHour = 3600;
                var requiredHours = 6;                schedule.MoveToDate(e.Date.AddSeconds((dateComponents.Hour - requiredHours) * numberOfSecondsPerHour));
            }        }  

 

You can download the source code for entire demo of switching schedule view through event from here, ScheduleSample.


Conclusion

I hope you enjoyed learning how How to move to required time while switching from month view to day view.

You can refer to our Xamarin. iOS Schedule feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Xamarin. iOS Schedule example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied