Comments (9)
From my experience, kvo is not a good thing to use in many case. In your code, it's even worse because the observer is the object itself. It's a ScrollView, you could just override layoutSubviews.
Still, this feature is not part of this library, it's like you add a code for have rounded border, it doesn't require to be in he library for work.
from jtcalendar.
Hi @f33chobits I used this code and its crashing on deallocation because the KVO observers added to observe contentOffset property aren't deallocated correctly. I saw that your code correctly remove the observers on dealloc methods but the object observed is nil on dealloc call, leading to removeObserver:forKeyPath not being executed.
from jtcalendar.
Hey @yuriferretti .
Sorry I forgot to submit my fixing to this. This problem would come up because the menuView would call dealloc ahead of menuMonthView (parent view first). So I fixed this by enumerating and removing observers in menuView. But that shouldn't be right. I think I should use NSNotificationCenter instead, which would decouple the dependence bettween menuView and menuMonthView. What do you think about this?
from jtcalendar.
#52 implement a better way. The menuView only has one observer this time.
from jtcalendar.
Sorry, but i cannot accept this pull request for 2 reasons:
- first, you can just add a view over the
JTCalendarMenuView
which can reproduce the same effect, it will be cleaner and simpler - i will never accept a code with a try catch
from jtcalendar.
Try catch is indeed a bad solution, but is there another way to check whether there is an kvo observer yet?
from jtcalendar.
layoutSubviews is great! Thanks π
from jtcalendar.
@f33chobits I just moved your KVO observing code to JTCalendarMenuView's private method configureConstraintsForSubviews as @jonathantribouharet mentioned and it's working like a charm!!
from jtcalendar.
π
from jtcalendar.
Related Issues (20)
- JTCalendar display wrong number of dates in EST
- Can't change locale and timezone on Swift
- Find the height of a calendar cell
- about self->_menuView HOT 1
- How to scroll only one week?!
- How to change JTCalendarDayView height HOT 2
- XCode 10 GM and Swift 4.2 fail to build HOT 1
- JTCalendar Scrolling to next month - How do I set a particular day fixed towards the left when scrolled to next month in the view in Objective C? HOT 1
- JTCalendar not working in Swift 4.2 HOT 2
- setDate not working HOT 1
- Multiple Date
- property: pageViewNumberOfWeeks have bug? HOT 1
- Not scrolling to today date. HOT 1
- Need changes in week view
- Type Mismatch: Signed to Unsigned
- Carthage ιζ JTCalendarDelegate.h ζδ»ΆζΎδΈε°
- Date labels disappear and reappear when scrolling between months
- Show left and right arrows instead of month name HOT 1
- How to make disable swipe? HOT 1
- Need help setting up multiple week selection on single cell click event .
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 jtcalendar.