【问题标题】:Repeat UILocalNotification on certain days of week在一周中的某些日子重复 UILocalNotification
【发布时间】:2011-05-09 14:46:38
【问题描述】:

我想将 UILocalNotification 的重复间隔自定义为一周中的某些天。我没有找到任何相关信息。

如何设置一周中某些天的通知重复间隔,例如,在星期日、星期一和星期五重复通知?

【问题讨论】:

  • 我也有同样的问题

标签: ios cocoa-touch uilocalnotification


【解决方案1】:

很遗憾,您不能将UILocalNotificationrepeatInterval 属性设置为仅在特定日期重复。您可以设置每天(每天)、每月(每个月)或每小时(每小时)重复。因此,对于您的问题,唯一可行的解​​决方案是,如果您想在周日、周一和周二设置闹钟,那么您必须设置 3 个闹钟(周日、周一和周二各一个),而不是一个闹钟。

【讨论】:

    【解决方案2】:

    如果您需要自定义repeatInterval 属性。您必须在指定时间设置每个UILocalNotification。这是我的代码。

    
        void (^insertAlarm)(NSDate*fire,NSString*sound,int alarmCount) = ^(NSDate*fire,NSString*sound,int alarmCount){
            UILocalNotification* notification = [[UILocalNotification alloc] init];
            notification.timeZone = [NSTimeZone defaultTimeZone];
            notification.soundName = sound;
            notification.fireDate = fire;
            notification.repeatInterval = 0;
            notification.alertLaunchImage = IMG;
            notification.alertAction = ACTION_MSG;        
            notification.alertBody = BODY;
            notification.applicationIconBadgeNumber = 1;
            [[UIApplication sharedApplication] scheduleLocalNotification:notification];
            [notification release];
        };
    
        insertAlarm(date,sound.fileName,0);
        insertAlarm([date dateByAddingTimeInterval:60],sound.fileName,1);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-21
      • 2019-08-29
      • 2013-01-04
      • 2020-02-10
      • 1970-01-01
      • 2014-02-24
      • 1970-01-01
      相关资源
      最近更新 更多