DDCalendarView icon indicating copy to clipboard operation
DDCalendarView copied to clipboard

scrollRectToVisible not working current date and time

Open sanojKashyap opened this issue 8 years ago • 9 comments

I just want to scroll view need to show current time onwards event.Later user can scroll. So suppose if any event starting in 5 Pm then scroll view should load from 4 PM, scrolling again can see all event.

sanojKashyap avatar May 23 '16 18:05 sanojKashyap

the calendar view has - (void)scrollDateToVisible:(NSDate* _Nonnull)date animated:(BOOL)animated;

does that not work?

Daij-Djan avatar May 25 '16 11:05 Daij-Djan

Its not working. I should load view from as per current time On 25-May-2016 5:08 PM, "Dominik Pich" [email protected] wrote:

the calendar view has - (void)scrollDateToVisible:(NSDate* _Nonnull)date animated:(BOOL)animated;

does that not work?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/Daij-Djan/DDCalendarView/issues/6#issuecomment-221547858

sanojKashyap avatar May 25 '16 11:05 sanojKashyap

can you show me a sample example? the code you have... it works fine on my end

Daij-Djan avatar May 28 '16 11:05 Daij-Djan

updated my control with week view, more l&f and performance - awaiting bugreports before pushing it out via #cocoapods

Daij-Djan avatar May 29 '16 20:05 Daij-Djan

the not scrolling seems to be random but I can sometimes reproduce it

Daij-Djan avatar May 29 '16 20:05 Daij-Djan

Hey, could you please, let me know required to change to fix the issue, i have done a lot of changes in last version, which is not possible to revert it back. If you tell me changes which I can implement make previous version work?

sanojKashyap avatar Jun 08 '16 05:06 sanojKashyap

Hi I'm having the same issue here, Once I'm on CalendarView:focussedOnDay, I check if I have an event for that day, if I have an event I'm trying to show the first one scrolling to it, if not, I'm trying to scroll to 7:00am. Sometimes it works, sometimes it does not. My current timezone is UTC-3.

I'm checking the DDCAlendarSingledayView pointForDate, but I cannot understand the logic there. I will keep you posted if I found something.

Thank you so much!

fjsosa avatar Mar 04 '17 00:03 fjsosa

It seems there is something related with these lines in [DDCalendarSingleDayView pointToDate:]

//we only encompass prev and next day.. we dont care about 2 or more days
if(compsOfBegin.day > compsNow.day) beginInHoursSinceMidnightToday += 24;
else if(compsOfBegin.day < compsNow.day) beginInHoursSinceMidnightToday -= 24;

I've commented out this portion of code, and it seems to work, maybe I'm missing something, or I broke somethign else.

fjsosa avatar Mar 04 '17 00:03 fjsosa

Just to show the as events start from time I have modified it like,

  • (void)showPreviewForDate:( nullable NSDate *)startDate { dispatch_async(dispatch_get_main_queue(), ^{ [self.centerCal setContentOffset:CGPointMake(0,[self getDynamicYAxisFor:startDate]) animated:NO]; });

}

#pragma mark - Calculate Y Axis for

  • (int)getDynamicYAxisFor:(NSDate *)date{

    NSCalendar *gregorianCal = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; NSDateComponents *dateComps = [gregorianCal components: (NSCalendarUnitHour | NSCalendarUnitMinute) fromDate: date]; int mins =(int)[dateComps minute]; int hr =(int)[dateComps hour]; int yForCurrentTime = (((hr)60) + mins).8333 +14; return yForCurrentTime-50; }

These two method seems failing for me

  • (void)scrollDateToVisible:(NSDate* _Nonnull)date animated:(BOOL)animated;
  • (void)showPreviewForDate:(nullable NSDate *)startDate ; so I got another way as above explained.

But still, my solutions does not work in the exceptional scenario. I have to work on this.

Please, add current time in the project and when you view loads it must scroll to your current time. you component is awesome but needs some fixes.

screen shot 2017-03-04 at 8 51 14 pm

Let me know if you have any question.

sanojKashyap avatar Mar 04 '17 15:03 sanojKashyap