当使用以下格式在日历中添加事件时,它在日历警报中添加如下内容:
"1 day before",但我想作为
"At the time of event"下面是我的代码,
calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSString *cday,*cmonth,*cyear;
// set today
today = [[NSDate alloc] initWithTimeIntervalSinceNow:1];
//set the current day to show the calendar
NSDateFormatter *temp1 = [[NSDateFormatter alloc] init];
[temp1 setDateFormat:@"dd"];
cday=[temp1 stringFromDate:today];
NSLog(@"Date checking%@",cday);
[temp1 release];我的代码出了什么问题?有没有人能帮我整理一下?
发布于 2013-03-21 18:11:27
可能跟时区有关。您可能需要为NSDateFormatter object.Please的timeZone属性设置适当的值将时区设置为本地时区
[temp1 setTimeZone:[NSTimeZone systemTimeZone]];
(or)
[temp1 setTimeZone:[NSTimeZone localTimeZone]];请将此代码放入:
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSString *cday,*cmonth,*cyear;
// set today
NSDate *today = [NSDate date];
//set the current day to show the calendar
NSDateFormatter *temp1 = [[NSDateFormatter alloc] init];
[temp1 setTimeZone:[NSTimeZone localTimeZone]];
[temp1 setDateFormat:@"dd"];
cday=[temp1 stringFromDate:today];
NSLog(@"Date checking%@",cday);
[temp1 release];https://stackoverflow.com/questions/15544513
复制相似问题