PMCalendar icon indicating copy to clipboard operation
PMCalendar copied to clipboard

How to set currentDate to show selected month calendar

Open avocet opened this issue 12 years ago • 21 comments

Sorry, I don't know how to set currentDate in PMDaysView ? [PMCalendarController setCurrentDate: ] is right to set currentDate ?

avocet avatar Sep 13 '12 17:09 avocet

Yes.

-Pavel

On Sep 13, 2012, at 7:04 PM, avocet [email protected] wrote:

Sorry, I don't know how to set currentDate in PMDaysView ? [PMCalendarController setCurrentDate: ] is right to set currentDate ?

— Reply to this email directly or view it on GitHubhttps://github.com/kovpas/PMCalendar/issues/7.

kovpas avatar Sep 13 '12 17:09 kovpas

But I can't do it in my codes! as in picture below, https://picasaweb.google.com/lh/photo/AEnbhkFjd_tROED6kCTNMdMTjNZETYmyPJy0liipFm0?feat=directlink

avocet avatar Sep 14 '12 11:09 avocet

Looks like another thing which is missing, yes. Will look into this when I have enough time.

Thanks.

kovpas avatar Sep 14 '12 11:09 kovpas

Hi I added the project to my project. I can show the calendar but when I pressed the next or previous month button I get this message; I cant show the next or previous month of the year...

[__NSDate monthStartDate]: message sent to deallocated instance what can I do for this... Please help me...

This is my code

self.pmCC = [[PMCalendarController alloc] initWithThemeName:@"default"]; pmCC.delegate = self; pmCC.mondayFirstDayOfWeek = NO; [pmCC presentCalendarFromRect:CGRectZero inView:[self.view superview] permittedArrowDirections:PMCalendarArrowDirectionAny animated:YES]; [self calendarController:pmCC didChangePeriod:pmCC.period];

kemalserkan avatar Sep 18 '12 08:09 kemalserkan

Hi,

Have you tried to run enclosed demo project? Does it work?

kovpas avatar Sep 18 '12 08:09 kovpas

Yes demo is working correctly...

kemalserkan avatar Sep 18 '12 08:09 kemalserkan

I call the calender from a UIBarButton is that affect ?

kemalserkan avatar Sep 18 '12 08:09 kemalserkan

Not sure. Obviously NSDate object is being released somewhere in an incorrect place, but I don't see anything wrong in your code.

kovpas avatar Sep 18 '12 09:09 kovpas

Ok I will look is there another NSDate object that released.. Thank you so much...

kemalserkan avatar Sep 18 '12 09:09 kemalserkan

There is NSDate object that I take the currentDate to use another function. But I dont release any of that object. :(

kemalserkan avatar Sep 18 '12 09:09 kemalserkan

Language can affect this error. I am from Türkiye.

kemalserkan avatar Sep 18 '12 09:09 kemalserkan

In PMCalendarView.m file

in - (void)drawRect:(CGRect)rect function

NSDate *dateOnFirst = [_currentDate monthStartDate]; on this row throw this error

-[__NSDate monthStartDate]: message sent to deallocated instance 0xacbe060

When I pressed the next or previous month...

kemalserkan avatar Sep 18 '12 09:09 kemalserkan

That's weird. currentDate has a strong reference, it shouldn't be released.

kovpas avatar Sep 18 '12 09:09 kovpas

Is there any solution we can do

kemalserkan avatar Sep 18 '12 10:09 kemalserkan

To be honest, I have no idea what could be wrong in the code you've wrote. As long as demo project works, I assume that the problem is on your side.

-Pavel

On Sep 18, 2012, at 12:58 PM, Kemal Serkan YILDIRIM < [email protected]> wrote:

Is there any solution we can do

— Reply to this email directly or view it on GitHubhttps://github.com/kovpas/PMCalendar/issues/7#issuecomment-8649881.

kovpas avatar Sep 18 '12 11:09 kovpas

Thank you so much

kemalserkan avatar Sep 18 '12 11:09 kemalserkan

if Objective-C ARC set to NO, error In PMCalendarView.m file

in - (void)drawRect:(CGRect)rect function

NSDate *dateOnFirst = [_currentDate monthStartDate]; on this row throw this error

-[__NSDate monthStartDate]: message sent to deallocated instance 0xacbe060

rinonita avatar Dec 06 '12 08:12 rinonita

ARC is supposed to be turned on.

kovpas avatar Dec 06 '12 08:12 kovpas

[__NSDate numberOfDaysInMonth]: message sent to deallocated instance 0x32072ff0

I try again to add PMCalendar to my project..

I get that message...

kemalserkan avatar Feb 13 '13 19:02 kemalserkan

If you find a way to fix that, please make a pull request.

kovpas avatar Feb 13 '13 19:02 kovpas

to solve this problem just replace NSDateComponents *eComponents = [gregorian components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:_currentDate]; with NSDateComponents *eComponents = [gregorian components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:[_currentDate copy]];

pmcalendarview.m

mchbaro avatar Sep 12 '13 13:09 mchbaro