我需要设置 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];
问题 1 =>我无法理解你想要什么。(但是如果您只想显示日期名称,例如周日、周一、...至周六然后使用UIPickerView。 http://cocoamatic.blogspot.in/2010/08/create-uipickerview-programmatically.html)
问题 2 => YES
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)