Question

I don't know how many people have used this library, but I am using it to display various events taking place in the month of April. Currently when I add the calendar view into the application, it defaults to today's date and shows March.

Does anyone know how I can get it to default to April as opposed to today's date? I am sure this can be done I am just not sure where in the code I need to hardcode in a date or something.

Was it helpful?

Solution

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
        calendar =  [[TKCalendarMonthView alloc] init];
        calendar.delegate = self;
        calendar.dataSource = self;

        NSString *str=[NSString stringWithFormat:@"2012-04-04"];
        NSDateFormatter *df=[[NSDateFormatter alloc] init];
        [df setDateFormat:@"yyyy-MM-dd"];

        NSDate *date1=[df dateFromString:str];

        [calendar selectDate:date1];
        [self.view addSubview:calendar];
    }
    return self;
}

Use this code where you want to display the calendar.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top