Comments (2)
I'm looking into this issue and issue #57. I'm having trouble reproducing. Can you please provide a code sample?
from mbcalendarkit.
So I looked into this and worked it out.
When you tap on a day in the calendar, it creates an NSDate
object with a year, month, and day. The time values are all set to zero.
The NSDate
created by the "today" button in the CKCalendarViewController
and the NSDate
create by the calendar view on instantiation is created by calling [NSDate date]
. Those dates have hour, minute, and second values.
When trying to key into the data source dictionary, you're not going to match if you have time values specified. That's why tapping on a date shows events and the default date and the today button don't show events correctly.
There are two ways to fix this.
- Be stricter about setting dates. When setting an NSDate, we can use the current calendar to strip out anything but the year, month, and day values, like so:
NSDateComponents *components = [self.calendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate:date];
date = [self.calendar dateFromComponents:components];
- We can be looser about what dates we accept as "matches" in the data source. (That is, do less greedy matches in the calendar when we're checking for events.
Unless we need the precision of a stricter date in the calendar, we're better off, in my opinion, with the first option.
As it is now, the calendar does not manage events internally, and doesn't get more precise than the "day" unit. As such, there isn't much benefit to making that calculation of what dates fall into what ranges whenever there's a call to the data source. It seems more efficient to truncate the time part of the date once, when we set it.
I'm happy to say that commit cc7f098 implements the first of these two fixes.
from mbcalendarkit.
Related Issues (20)
- Bring `CustomCellProvider` to the HeaderView
- Cell Transition Animation Bug HOT 1
- Unit Test Cell Width Code
- CalendarView doesn't take in account firstDayOfWeek HOT 10
- Disable dragging on CustomCellProviding HOT 5
- Performance Profiling HOT 1
- Allow Custom Next/Back Images
- Month to Week Transition observable gap
- how refresh the data HOT 1
- how avoid show the tab bar HOT 1
- how to use background color in every sunday?
- Hello Project's Owner
- How to show more than one event in single date for MBCalendarKit for swift 4 HOT 1
- Changed it to NSCalendarIdentifierIslamic not working
- How to achieve calendar color customization? HOT 1
- How to change colors of calendar header, arrows, and selected cell?
- How to hide rows in Month display mode.
- Installing mBCalendarKit via Cocoapods is getting failed. HOT 1
- Calendar week view - pressing forwards/backwards buttons sometimes skips a week
- Tab Bar Text...
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mbcalendarkit.