gpt4 book ai didi

ios - UILocalNotification - repeatInterval 重置(不重复)

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:19:48 24 4
gpt4 key购买 nike

概览

  • 我正在根据 UILocalNotification 的现有实例创建通知
  • 现有实例已将 repeatInterval 设置为 NSWeekdayCalendarUnit

我想做什么

  • 我想将repeatInterval设置为不重复,

问题

  • 我应该将 repeatInterval 设置为什么常量才能使其不重复?

最佳答案

摘自 Apple 文档:

If you assign an calendar unit such as weekly (NSWeekCalendarUnit) or yearly (NSYearCalendarUnit), the system reschedules the notification for delivery at the specified interval. The default value is 0, which means don't repeat.

我假设您想取消具有重复间隔的通知,您可以通过两种方式做到这一点:

  1. 取消所有通知。
  2. 取消仅该通知。

第一个选项很简单,使用:

cancelAllLocalNotifications

在您的应用委托(delegate)中。

第二个需要更多的工作。您需要查看待处理的通知(使用 scheduledLocalNotifications)并取消通知。

为了知道哪些通知将被取消,您可以在设置通知时使用 userInfo 属性。例如,为每个通知设置一个唯一 ID,这样当您取消该通知时,您只需将该 ID 与 scheduledLocalNotifications 数组中的所有 ID 进行比较即可。

关于ios - UILocalNotification - repeatInterval 重置(不重复),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10359024/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com