1,主要就这几个类:
1,calendarpicker
2,
--------------------
1,uicontrol
2,uicalendar
3,cgcontaintpoint
4,protocol, many kind of providers
5,scrollview
6,animation
------------------
罗列分析法,
一,两类控件
1,button
2,uiview(布局和动画)
3,套餐:nsdate,uicalendar,nsdatecomponets,dateformatter
二,三个算法(先后顺序,相互作用关系)
1,日历
2,button 在uiview上的布局及动画
3,button状态 与日历的关系
--------------------
活动图
1,生成uiview------>初始化日期------》初始化button---------->button长到 view上面(uiview添加各种手势,button添加各种交互事件)
2,困惑 1,在几个view上初始化了 日期,是三个么?
2,怎样在一个日历当中,既有上一个月的日子,也有下一个月的日子?
------------------------------------------------------------------
1,恶心的代码
- (NSDate*)dateForRow:(NSInteger)row
andColumn:(NSInteger)column
{
NSInteger index = row*7 + column + 1;
NSDateComponents * comps = [self.calendarcomponents:NSDayCalendarUnit|NSWeekdayCalendarUnitfromDate:[self.dateOwnerhighlightedDate]];
NSInteger highlightedDay = comps.day;
NSInteger highlightedWeekday = comps.weekday - self.calendar.firstWeekday + 1;
NSInteger firstWeekday = (highlightedWeekday - highlightedDay + 35)%7 + 1;
comps.weekday = 0;
comps.day = index - firstWeekday - (highlightedDay-1);
return [self.calendardateByAddingComponents:comps toDate:[self.dateOwnerhighlightedDate] options:0];
}
1,选择好了的日期
2,日期组件
//获得当前日期
NSDate *date = [NSDate date];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *comps;
//本年
comps = [calendar components:(NSYearCalendarUnit) fromDate:date];
NSInteger year = [comps year];
//本月
comps = [calendar components:(NSMonthCalendarUnit) fromDate:date];
NSInteger month = [comps month];
//本月第一天的星期
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
NSTimeZone *timeZone = [NSTimeZone localTimeZone];
[formatter setTimeZone:timeZone];
[formatter setDateFormat:@"M/d/yyyy"];
NSString *firstDay = [NSString stringWithFormat:@"%d/%d/%d",month,1,year];
date = [formatter dateFromString:firstDay];
[formatter release];
comps = [calendar components:(NSWeekdayCalendarUnit) fromDate:date];
NSInteger weekday = [comps weekday];
//下月第一天
NSDateComponents *c1 = [[NSDateComponents alloc] init];
[c1 setMonth:1];
NSDate *date2 = [calendar dateByAddingComponents:c1 toDate:date options:0];
[c1 release];
//本月最后一天
NSDateComponents *c2 = [[NSDateComponents alloc] init];
[c2 setDay:-1];
NSDate *date3 = [calendar dateByAddingComponents:c2 toDate:date2 options:0];
[c2 release];
comps = [calendar components:(NSDayCalendarUnit) fromDate:date3];
NSInteger maxDays = [comps day];
---------------------------------------------
1,核心,一个选择了的日期,一个在 几行几列的一个定位,其它的选择 相对这个选择的日期,然后展开,因此初始化的这个日期很重要,它决定了所有的东西,比如:所在的年,月,日,周几,几行,几列,
-----------------
锁定几个可疑人物
1,- (void)tapDetected:(UITapGestureRecognizer *)recognizer
2,- (void)changeStateTo:(ABCalendarPickerState)toState
fromState:(ABCalendarPickerState)fromState
animation:(ABCalendarPickerAnimation)animation
canDiffuse:(NSInteger)canDiffuse《首先执行 四次》
3,- (void)updateButtonsForProvider:(id<ABCalendarPickerDateProviderProtocol>)provider andState:(ABCalendarPickerState)state《在changeStateTo里面调用》
4,- (NSDate*)dateForRow:(NSInteger)row andColumn:(NSInteger)column;<在updateButtonForProvider里面调用>
5,- (UIControlState)controlStateForDate:(NSDate*)date;<在updateButtonForProvider里面调用>