小编Ric*_*ick的帖子

在特定日期重复UILocalNotification

我需要设置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];
Run Code Online (Sandbox Code Playgroud)

iphone objective-c datepicker ios localnotification

6
推荐指数
1
解决办法
3797
查看次数

标签 统计

datepicker ×1

ios ×1

iphone ×1

localnotification ×1

objective-c ×1