请参阅以下代码
NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
[outputFormatter setDateFormat:@"h:mm a"];
NSDate *dat=pickerView.date;
NSString *timerString=[outputFormatter stringFromDate:dat];
[startTimer setTitle:timerString forState:UIControlStateNormal];
timeString=timerString;
[self updatePrayerTimigs];
//dat=[NSDate dateWithTimeIntervalSinceNow:20];
UILocalNotification *local=[[[UILocalNotification alloc]init] autorelease];
UIApplication *app=[UIApplication sharedApplication];
if(local){
local.fireDate=dat;
local.timeZone=[NSTimeZone defaultTimeZone];
//local.repeatInterval=0;
local.alertBody=@"Hello";
local.repeatInterval=NSMinuteCalendarUnit;
[app scheduleLocalNotification:local];
[app presentLocalNotificationNow:local];
}// end of the if
我只从UIDatePicker中选择时间(小时,分钟),所以我可以触发通知,所以我决定从UIDatePicker中选择将当前日期添加到上面的NSDate,请帮助我该怎么做
答案 0 :(得分:0)
尝试使用此格式化日期
NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
[outputFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];