【问题标题】:Snooze method in EventKit Framework?EventKit 框架中的贪睡方法?
【发布时间】:2011-03-14 07:00:57
【问题描述】:

我能够访问 EKEventStore 的所有功能,例如保存任何事件或从日历中删除任何事件。

但是如何为该事件创建贪睡,比如说我需要所有 saveEvent 的 15 分钟贪睡?

我没有发现这种方法

有人知道这种方法吗?

【问题讨论】:

标签: iphone objective-c icalendar eventkit


【解决方案1】:

如果您尝试在应用程序中设置某些功能在 15 秒延迟后执行,您可以使用以下内容:

[self performSelector:@selector(yourMethod) withObject:nil afterDelay:15];

EventKit 旨在为用户设置本地通知,无论用户是否正在运行您的应用程序,都可以显示这些通知。它们与推送通知完全一样,只是它们本地存储在用户设备上并且不需要网络连接。

如果您尝试向 EventKit 通知添加贪睡功能,您可以使用 ApplicationDidLoadWithOptions 方法在您的应用程序中实现它。每当用户单击本地通知上的“确定”按钮时,都会调用该方法。据我所知,EventKit 框架本身没有内置的贪睡功能。

【讨论】:

    【解决方案2】:

    我从未尝试过那个库,但您尝试过 NSTimer 吗?类似的东西:

    NSTimer *snoozeTimer;   
    //make it reachable in whole class
    
    //setting the snooze timer. 900 s = 15 min. change to "repeats:NO" if you want just one snooze.   
    
    snoozeTimer = [NSTimer scheduledTimerWithTimeInterval:900.0 target:self selector:@selector(someAlarmMethod) userInfo:nil repeats:YES];
    
    //and after finished snooze  
    [snoozeTimer invalidate];
    

    也许这不是您想要的,但它可能会起作用:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-26
      • 1970-01-01
      • 1970-01-01
      • 2019-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多