Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to rotate the hands of clock for the 24 hour clock?
    primarykey
    data
    text
    <p>I am working on a clock project, i know how to implement hands (Hour, Minute, Seconds) rotation of 12 hour clock. The code i have used is follows</p> <pre><code>CGFloat secAngle,minAngle,hourAngle; NSDateComponents *dateComponents = [[NSCalendar currentCalendar] components:(NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit) fromDate:[NSDate date]]; NSInteger seconds = [dateComponents second]; NSInteger minutes = [dateComponents minute]; NSInteger hours = [dateComponents hour]; if (timeFormat == 12)//12 hour clock { if (hours &gt; 12) hours -=12; //PM secAngle = Degrees2Radians(seconds/60.0*360); minAngle = Degrees2Radians(minutes/60.0*360); hourAngle = Degrees2Radians(hours/12.0*360) + minAngle/12.0; //secHand.transform = CATransform3DMakeRotation (secAngle+M_PI, 0, 0, 1); minHand.transform = CATransform3DMakeRotation (minAngle+M_PI, 0, 0, 1); hourHand.transform = CATransform3DMakeRotation (hourAngle+M_PI, 0, 0, 1); } else //24 hour clock { secAngle = Degrees2Radians(seconds/60.0*360); minAngle = Degrees2Radians(minutes/60.0*360); hourAngle = (30 * hours + minutes / 2) /2; //secHand.transform = CATransform3DMakeRotation(secAngle * M_PI / 180,0,0,1); minHand.transform = CATransform3DMakeRotation(minAngle * M_PI ,0,0,1); hourHand.transform = CATransform3DMakeRotation(hourAngle * M_PI,0,0,1); } </code></pre> <p>But when i try to implement the 24 hour clock. It is not working. Each time when i run this project the clock shows wrong timings. </p> <p>Can anyone tell me what wrong do i did. Many thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload