如何创建一个这样的日历 [英] How to create a calendar like this

查看:214
本文介绍了如何创建一个这样的日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个基于周的日历,它应该将UITableView中的日期作为列表显示。下面是我发布的图像,以清除所需的输出。已经经历了很多google,但没有任何解决方案。。已经走过许多日历KAl,Tapku和Mukhu,但没有得到任何解决方案。请指导。

I want to create a week based calendar, it should show the days in UITableView as a list. Below is image i have posted to clear the required output. Have gone through google a lot, but doesn't got any solution.. Have gone throgh many calendars KAl, Tapku and also Mukhu but not got any solution for it. Please guide.

推荐答案

多德尝试一下本作周,日视图

Dude try this for week and day view

https://github.com/muhku/calendar-ui

周或日视图可能会让你开始,或者如果你想从ios EventStore重新获取事件,并创建一个数据源,将数据提供给你的表。 。大多都日历组件做到这一点,你甚至可以采取从上面的组件

week or day view might get you started with or if you wan to start afresh fetch events from the ios EventStore and make a datasource that feeds data to your table. Mostly all calendar components do that, you can even take that from the above component.

使用这些方法来使日期:

Use these methods to make dates:

#define DATE_COMPONENTS (NSYearCalendarUnit| NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekCalendarUnit |  NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit | NSWeekdayCalendarUnit | NSWeekdayOrdinalCalendarUnit)

#define CURRENT_CALENDAR [NSCalendar currentCalendar]

+ (NSDate *)nextDayFromDate:(NSDate *)date {
    NSDateComponents *components = [CURRENT_CALENDAR components:DATE_COMPONENTS fromDate:date];
    [components setDay:[components day] + 1];
    [components setHour:0];
    [components setMinute:0];
    [components setSecond:0];
    return [CURRENT_CALENDAR dateFromComponents:components];
}

+ (NSDate *)previousDayFromDate:(NSDate *)date {
    NSDateComponents *components = [CURRENT_CALENDAR components:DATE_COMPONENTS fromDate:date];
    [components setDay:[components day] - 1];
    [components setHour:0];
    [components setMinute:0];
    [components setSecond:0];
    return [CURRENT_CALENDAR dateFromComponents:components];
}

将日期组织成一周 - 将这些日期组成一个星期。使用此方法以星期号表示星期几:

Organise dates into a week - group those dates to form a week. Take day of week by day number using this method:

+ (NSString *)dayNameForWeekDay:(int)weekday
{
    switch (weekday) {
        case 1:
            return @"Sunday";
            break;
        case 2:
            return @"Monday";
            break;
        case 3:
            return @"Tuesday";
            break;
        case 4:
            return @"Wednesday";
            break;
        case 5:
            return @"Thursday";
            break;
        case 6:
            return @"Friday";
            break;
        case 7:
            return @"Saturday";
            break;
        default:
            break;
    }

    return @"";
}

并使用数据源显示事件。自定义表格不是一件大事,展开折叠非常简单。

And using the datasource show the events. Customizing your table is not a big deal, expanding collapsing is so simple.

这篇关于如何创建一个这样的日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆