0
24 시간이 지나면 번호가 1에서 2로, 2에서 3으로 바뀌는 것을 감지하는 루프를 만들어야합니다. 31까지입니다. 31 일 때 31이라고 말합니다. 그러나 number가 내 tab-bar 심볼에 있고 quartz를 사용하여 숫자를 그렸습니다. 따라서 숫자는 정수가 아니라 숫자가 쓰여진 nsstring입니다. 오늘 날짜 17 일 때 표시되는 숫자는 6입니다. 내가 어디로 잘못 가고 있는지 확실하지 않습니까?날짜가 바뀌면 변경할 날짜가 표시되는 번호가 필요합니까?
- (void)updateLabelForDate:(NSDate *)date {
NSTimeInterval timeInterval = [date timeIntervalSinceReferenceDate];
NSInteger days = timeInterval/(60*60*24);
NSArray *sloganArray = [NSArray arrayWithObjects:
NSLocalizedString(@"1", nil),
NSLocalizedString(@"2", nil),
NSLocalizedString(@"3", nil),
NSLocalizedString(@"4", nil),
NSLocalizedString(@"5", nil),
NSLocalizedString(@"6", nil),
NSLocalizedString(@"7", nil),
NSLocalizedString(@"8", nil),
NSLocalizedString(@"9", nil),
NSLocalizedString(@"10", nil),
NSLocalizedString(@"11", nil),
NSLocalizedString(@"12", nil),
NSLocalizedString(@"13", nil),
NSLocalizedString(@"14", nil),
NSLocalizedString(@"15", nil),
NSLocalizedString(@"16", nil),
NSLocalizedString(@"17", nil),
NSLocalizedString(@"18", nil),
NSLocalizedString(@"19", nil),
NSLocalizedString(@"20", nil),
NSLocalizedString(@"21", nil),
NSLocalizedString(@"22", nil),
NSLocalizedString(@"23", nil),
NSLocalizedString(@"24", nil),
NSLocalizedString(@"25", nil),
NSLocalizedString(@"26", nil),
NSLocalizedString(@"27", nil),
NSLocalizedString(@"28", nil),
NSLocalizedString(@"29", nil),
NSLocalizedString(@"30", nil),
NSLocalizedString(@"31", nil),
nil];
NSInteger usedSloganIndex = (int)days % [sloganArray count];
slogan = [sloganArray objectAtIndex:usedSloganIndex];
NSLog(@"Slogan: %@", slogan);
NSLog(@"%i",usedSloganIndex);
int x,y,width,height;
x = 23;
y = 440;
width = 20;
height = 20;
CustomBadge *customBadge1 = [CustomBadge customBadgeWithString:slogan];
- (void)applicationSignificantTimeChange:(UIApplication *)application {
[self updateLabelForDate:[NSDate date]];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[self updateLabelForDate:[NSDate date]];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the tab bar controller's view to the window and display.
[window addSubview:tabBarController.view];
[self addTabBarArrow];
[window makeKeyAndVisible];
[self updateLabelForDate:[NSDate date]];
return YES;
}
감사
내 질문이 업데이트되었습니다. – Dangermouse
오늘 날짜를 원하면 'NSDateComponents'를 사용하십시오. 당신이 한 수학은 현재의 날짜와 아무런 관련이 없습니다. 하루의 초 수를 초 단위로 나눈 다음 모듈로 31을 취했습니다. 그 숫자는 의미있는 그레고리 안 날짜와 아무런 관련이 없습니다. 한 달 평균 일 수도 없습니다. –