weilsonwonder / WWCalendarTimeSelector

A android inspired iOS date/time picker
MIT License
317 stars 126 forks source link

Time value changed after switching AM and PM #59

Closed sgermain06 closed 6 years ago

sgermain06 commented 6 years ago

For some reason, if I present a time selector, I can select an hour and then change from AM to PM. After changing AM/PM, the value of the hour I selected changes. Is it possible to retain the selected hour value when changing AM/PM?

sgermain06 commented 6 years ago

I found the problem. The problem is that the touchesMoved: method was being called every time the view was touched, regardless of where, calling touchClock:. That method is selecting a time based on an angle calculation from the center of the view. Touching AM/PM was triggering that method, calculating that AM meant 7 o'clock was selected, same as PM, selecting 5 o'clock.

I added a check to the touchesMoved: method to see if the touch is within the bounds for the AM and PM buttons and if not, call touchClock:. Now the selected time remains.

EngSojoud90 commented 5 years ago

I found the problem. The problem is that the touchesMoved: method was being called every time the view was touched, regardless of where, calling touchClock:. That method is selecting a time based on an angle calculation from the center of the view. Touching AM/PM was triggering that method, calculating that AM meant 7 o'clock was selected, same as PM, selecting 5 o'clock.

I added a check to the touchesMoved: method to see if the touch is within the bounds for the AM and PM buttons and if not, call touchClock:. Now the selected time remains.

please can you provide me clear solution