作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试为一周中特定几天的提醒创建本地通知。
这就是我到目前为止所做的事情
let calender = NSCalendar.currentCalendar()
let notification = UILocalNotification()
notification.soundName = UILocalNotificationDefaultSoundName
notification.userInfo = NSDictionary(objects: [employee.deptID!], forKeys: [“deptID”]) as [NSObject : AnyObject]
if #available(iOS 8.2, *) {
notification.alertTitle = employee.Name
} else {
}
notification.alertBody = "Its time to remind you about today’s target"
let dc = calender.components([NSCalendarUnit.Weekday , NSCalendarUnit.Hour , NSCalendarUnit.Minute, NSCalendarUnit.Second], fromDate: timePicker.date)
dc.weekday = 4
notification.repeatInterval = NSCalendarUnit.Weekday // TODO :
notification.fireDate = calender.dateFromComponents(dc)
UIApplication.sharedApplication().scheduleLocalNotification(notification)
但是,上面的代码每天都会在那个特定时间触发。我希望通知在特定工作日的特定时间触发。
上面的代码有什么错误?
最佳答案
尝试改变
notification.repeatInterval = NSCalendarUnit.Weekday
到
notification.repeatInterval = NSCalendarUnit.WeekOfYear
关于ios - 即使将 repeatInterval 设置为工作日后,UILocalNotification 每天都会触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35708677/
2016 年 2 月 10 日安装 Windows 更新后,Azure 角色未在模拟器(完整/快速)中启动。日志如下所示 [00005748:00006624, 2016/02/14, 12:03:2
我是一名优秀的程序员,十分优秀!