i am having 10 images from 0-10 for setting the hour and minutes of my digital clock .i am getting confused on how to set a custom image to digital clock so that it will start working. Please anybody help me in solving my problem .Thanks.
this is my code
- (void)viewDidLoad {
//timer to recursively call the showClock method.
timer=[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(showClock) userInfo:nil repeats:YES];
[super viewDidLoad];
}
-(void)showClock
{
NSDate *dateShow= [NSDate dateWithTimeIntervalSinceNow:0];
NSDateFormatter *dateFormat = [[[NSDateFormatter alloc] init] autorelease];
[dateFormat setTimeStyle:NSDateFormatterMediumStyle];
NSString *dateString = [dateFormat stringFromDate:dateShow];
NSDate * date = [NSDate date];
NSCalendar * calendar = [[NSCalendar alloc]
initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents * components =
[calendar components:(NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:date];
NSInteger hour = [components hour];
NSInteger minute = [components minute];
NSInteger firstHourDigit = hour/60;
NSInteger secondHourDigit = hour%60;
NSInteger firstMinuteDigit = minute/60;
NSInteger secondMinuteDigit = minute%60;
[minfirstImage setImage:[UIImage imageNamed:[NSString stringWithFormat:@"0.png", firstHourDigit]]];
[minsecondImage setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%0.png",secondHourDigit]]];
[secfirstImage setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%0.png",firstMinuteDigit]]];
[secSecondImage setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%0.png",secondMinuteDigit]]];
}
不與圖像顯示。什麼可能是problem.Is在iphone小時,秒的自定義圖像數字時鐘在計算他們的任何問題如何創建具有
你知道^ h與UIImageView一起工作? – taskinoor
@taskinoor是的,我知道與uiimageview – Rani
工作實際上是什麼問題?你不知道如何維護一個計時器,或者你不知道如何獲得當前時間,或者你不知道如何根據計時器改變圖像?請更具體一些。 – taskinoor