大屏日历异步加载每天比赛数目并显示在日历里

#import <QuartzCore/QuartzCore.h>
#import "CalendarController.h"
#import "TdCalendarView.h"
#import "WaitDialog.h"
#import "JSONParser.h"
#import "FunUtil.h"
@implementation CalendarController
@synthesize calendarView;
@synthesize currentSelectDate;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = @"比赛时间";
		//self.view.backgroundColor = [UIColor whiteColor];
		//self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"back.png"]]; 
		calendarView = [[TdCalendarView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
		calendarView.backgroundColor = [UIColor whiteColor];
		//calendarView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"back.png"]]; 
		[self.view addSubview:calendarView];
		[calendarView setDayFlag:15 flag:-1];
		calendarView.calendarViewDelegate = self;
    }
    return self;
}

- (void) selectDateChanged:(CFGregorianDate) selectDate{
	currentSelectDate = selectDate;
	NSLog(@"selectDateChanged catch:%d年%d月%d日",selectDate.year,selectDate.month,selectDate.day);
}
- (void) monthChanged:(CFGregorianDate) currentMonth viewLeftTop:(CGPoint)viewLeftTop height:(float)height{
	NSLog(@"monthChanged catch:%d",currentMonth.month);
	self.currentSelectDate = currentMonth;
	[NSThread detachNewThreadSelector:@selector(fetchdata) toTarget:self withObject:nil];
}
- (void) beforeMonthChange:(TdCalendarView*) calendarView willto:(CFGregorianDate) currentMonth{
	[[self calendarView] clearAllDayFlag];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code.
}
*/

- (void)viewDidAppear:(BOOL)animated{
	[super viewDidAppear:animated];
	
}
-(void)fetchdata{
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
	[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
	int maxDay = [[self calendarView] getDayCountOfaMonth:currentSelectDate];
	NSString *dataURL =@"";
	NSLog(@"dataURL:%@",dataURL);
	NSArray *data = [JSONParser loadData:dataURL isAllValues:NO valueForKey:@"list"];
	[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
	[self performSelectorOnMainThread:@selector(showCount:) withObject:data waitUntilDone:NO];
	[pool release];
}
-(void)showCount:(NSArray *)data{
	int count = [data count];
	NSLog(@"showChange:%d",count);
	for(int i = 0;i<count-1;i++){
		NSArray *bf = [data objectAtIndex:i];
		if([bf valueForKey:@"day"]!=nil){
			int day = [[bf valueForKey:@"day"]intValue];
			int count = [[bf valueForKey:@"count"]intValue];
			[calendarView setDayFlag:day flag:count];
		}
	}
	[calendarView setNeedsDisplay];
}

- (void)dealloc {
	[calendarView release];
    [super dealloc];
}


@end
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值