【发布时间】:2014-02-24 06:15:42
【问题描述】:
我需要设置 UILocalNotification,我只需要从 DatePicker 中获取小时和分钟,并且需要设置特定的日期(例如:星期一)并在每个星期一重复。
我有两个问题:
第一个;是否可以在日期选择器的日期部分仅显示“星期天”之类的“日期名称”?
第二个问题是;如果我想为本地通知设置特定日期,正确的代码是什么?
感谢您的回答,下面是我的代码;
-(IBAction) alarmButton:(id)sender {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
dateFormatter.timeZone = [NSTimeZone defaultTimeZone];
dateFormatter.timeStyle = NSDateFormatterShortStyle;
dateFormatter.dateStyle = NSDateFormatterShortStyle;
NSString *dateTimeString = [dateFormatter stringFromDate: dateTimePickerSet1.date];
NSLog ( @"Alarm Set :%@" , dateTimeString);
[self scheduleLocalNotificationWithDate1: dateTimePickerSet1.date];
}
-(void)scheduleLocalNotificationWithDate1:(NSDate *)fireDate {
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = fireDate;
notification.alertBody = @"Alarm Set !";
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
【问题讨论】:
标签: ios iphone objective-c datepicker localnotification