- (void)loadView {
[super loadView];
calendarView = [[[KLCalendarView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 360) delegate:self] autorelease];
myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,260,320,160) style:UITableViewStylePlain];
myTableView.dataSource = self;
myTableView.delegate = self;
UIView *myHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0,0,myTableView.frame.size.width , 20)];
myHeaderView.backgroundColor = [UIColor grayColor];
[myTableView setTableHeaderView:myHeaderView];
[self.view addSubview:myTableView];
[self.view addSubview:calendarView];
[self.view bringSubviewToFront:myTableView];
}
- (void)calendarView:(KLCalendarView *)calendarView tappedTile:(KLTile *)aTile{
NSLog(@"Date Selected is %@",[aTile date]);
[aTile flash];
if(tile == nil)
tile = aTile;
else
[tile restoreBackgroundColor];
tile = aTile;
}
- (KLTile *)calendarView:(KLCalendarView *)calendarView createTileForDate:(KLDate *)date{
CheckmarkTile *tile = [[CheckmarkTile alloc] init];
//tile.checkmarked = YES;//based on any condition you can checkMark a tile
return tile;
}
- (void)didChangeMonths{
UIView *clip = calendarView.superview;
if (!clip)
return;
CGRect f = clip.frame;
NSInteger weeks = [calendarView selectedMonthNumberOfWeeks];
CGFloat adjustment = 0.f;
switch (weeks) {
case 4:
adjustment = (92/321)*360+30;
break;
case 5:
adjustment = (46/321)*360;
break;
case 6:
adjustment = 0.f;
break;
default:
break;
}
f.size.height = 360 - adjustment;
clip.frame = f;
CGRect f2 = CGRectMake(0,260-adjustment,320,160+adjustment);
myTableView.frame = f2;
[self.view bringSubviewToFront:myTableView];
tile = nil;
}
#pragma mark tableViewDelegate Methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
[cell setText:@"No Data For Now"];
return cell;
}
Thanks a lot for this tutorial. Great work
ReplyDeletehihi, im new in imac programming. Just to check with you, what would be the code if I would like to highlight a specific range of date in the calendar? For example, from 4th June 2009-28th June 2009 I would like to highlight it and set the cell at "No data for now" as School Holidays.. Could you guide me on how to do it? Thanks alot! (:
ReplyDeleteLike you approach.
ReplyDeleteI need a simple custom calendar developed.
Let me know if you are interested.
jP
TherasoftOnline,
ReplyDeleteyou can send over the details on my email: ved.redjack@gmail.com
can't download the CalenderTest.zip file. Can you post it again?
ReplyDelete@above: I just confirmed, download link is working...can you check again?
ReplyDeleteHi Ved I really apprecaite this post. I am also an Iphone developer, and looking to create some custom controls, as making Round Rect button in 75degree angle, and slice and use it in such manner that i won't occupy much space.
ReplyDeleteI new this command for making custom button as CGRectMake:(x,y,width, height), now how make a pentagonal button with UIKit.h
Hi Umaid,
ReplyDeleteYou can make an image of any shape you want and use [button setImage: forState:]
try playing with it, I have used it almost everytime I needed a custom shape button.
please tell me those function where i change the tile color and if i want to set the tile image then kindly tell me...
ReplyDeleteplease tell me exact class and function where i would change the tile's
What a great post, I actually found it very thought provoking, thanks iphone
ReplyDeleteNice Topic about IPhone.
ReplyDeleteI would also like to share iphone application development topic. i hope you all guys found some usefull information.
Beautifully explored. web development companies are offering custom iPhone application development to put your ideas into existence.
ReplyDeleteiphone developer
Hello,
ReplyDeleteNice blog i like it
This will help communicate with your developer and make things run smoother.
Hire iphone Developer
Hi, I use this code for my project for ipad, but as I go to next or previous month calendar dimension automatically change. I have read whole calendar code but nothing get.
ReplyDeleteif you dont need to change the dimensions, just do nothing inside the didChangeMonths() method
ReplyDeleteipad development
ReplyDeleteHey is the project for MAC OSX.
ReplyDeleteI thought it would be for Iphone!?