<tfoot id='xA0iG'></tfoot>
    1. <small id='xA0iG'></small><noframes id='xA0iG'>

      <legend id='xA0iG'><style id='xA0iG'><dir id='xA0iG'><q id='xA0iG'></q></dir></style></legend>

    2. <i id='xA0iG'><tr id='xA0iG'><dt id='xA0iG'><q id='xA0iG'><span id='xA0iG'><b id='xA0iG'><form id='xA0iG'><ins id='xA0iG'></ins><ul id='xA0iG'></ul><sub id='xA0iG'></sub></form><legend id='xA0iG'></legend><bdo id='xA0iG'><pre id='xA0iG'><center id='xA0iG'></center></pre></bdo></b><th id='xA0iG'></th></span></q></dt></tr></i><div id='xA0iG'><tfoot id='xA0iG'></tfoot><dl id='xA0iG'><fieldset id='xA0iG'></fieldset></dl></div>

      • <bdo id='xA0iG'></bdo><ul id='xA0iG'></ul>

      1. UILocalNotification 应该在每个工作日重复,但也会在

        时间:2023-05-30
          <bdo id='2Pasu'></bdo><ul id='2Pasu'></ul>
          1. <small id='2Pasu'></small><noframes id='2Pasu'>

                <tfoot id='2Pasu'></tfoot>
                  <tbody id='2Pasu'></tbody>

                • <legend id='2Pasu'><style id='2Pasu'><dir id='2Pasu'><q id='2Pasu'></q></dir></style></legend>
                  <i id='2Pasu'><tr id='2Pasu'><dt id='2Pasu'><q id='2Pasu'><span id='2Pasu'><b id='2Pasu'><form id='2Pasu'><ins id='2Pasu'></ins><ul id='2Pasu'></ul><sub id='2Pasu'></sub></form><legend id='2Pasu'></legend><bdo id='2Pasu'><pre id='2Pasu'><center id='2Pasu'></center></pre></bdo></b><th id='2Pasu'></th></span></q></dt></tr></i><div id='2Pasu'><tfoot id='2Pasu'></tfoot><dl id='2Pasu'><fieldset id='2Pasu'></fieldset></dl></div>
                • 本文介绍了UILocalNotification 应该在每个工作日重复,但也会在周末触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有一个 UILocalNotification 应该每天触发一次,从周一到周五,但不是在周末.我认为将通知的 repeatInterval 属性设置为 NSWeekdayCalendarUnit 可以完成此操作.对我来说可悲的是,我的通知仍然在周末触发.谁能建议为什么?这是我的代码:

                  I have a UILocalNotification that is supposed to fire once a day, Monday through Friday, but not on the weekend. I thought that setting the repeatInterval property of the notification to NSWeekdayCalendarUnit would accomplish this. Sadly for me, my notifications are still firing on the weekend. Can anyone suggest why? Here is my code:

                  UILocalNotification *localNotification = [[UILocalNotification alloc] init];
                  
                  localNotification.alertAction = @"View";
                  localNotification.alertBody = NSLocalizedString(@"ALERT_MESSAGE", nil);
                  localNotification.soundName = UILocalNotificationDefaultSoundName;
                  
                  NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
                  [dateFormatter setDateFormat:@"MM-dd-yyyy HH:mm"];
                  [dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"America/Toronto"]];
                  
                  // Notification fire times are set by creating a notification whose fire date 
                  // is an arbitrary weekday at the correct time, and having it repeat every weekday
                  NSDate *fireDate = [dateFormatter dateFromString:@"01-04-2012 11:00"]; 
                  
                  localNotification.fireDate = fireDate;
                  localNotification.repeatInterval = NSWeekdayCalendarUnit;
                  [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
                              break;
                  
                  [localNotification release];
                  

                  推荐答案

                  iOS 中的工作日仅表示一周中的一天.它没有工作周";内涵而不是周末.

                  Weekday in iOS just means a day inside of a week. It doesn't have the "work week" connotation as opposed to a weekend.

                  文档说得更清楚一点,建议您使用 1-7 作为单位:

                  The documentation says it a little clearer, by suggesting that you use 1-7 as the units:

                  NSWeekdayCalendarUnit

                  NSWeekdayCalendarUnit

                  指定工作日单位.

                  对应的值为 kCFCalendarUnitSecond.等于 kCFCalendarUnitWeekday.工作日单位是从 1 到 N 的数字(对于公历 N=7,1 是星期日).

                  The corresponding value is an kCFCalendarUnitSecond. Equal to kCFCalendarUnitWeekday. The weekday units are the numbers 1 through N (where for the Gregorian calendar N=7 and 1 is Sunday).

                  来源:http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSCalendar_Class/Reference/NSCalendar.html

                  为了正确设置周一到周五的通知,这里有一些框架代码.你必须执行 5 次,所以最好将它封装在一个为 fireDate 提供参数的方法中.我已经向你展示了如何在星期一做到这一点.

                  To properly set your notifications from Monday through Friday, here's some skeleton code. Yo'll have to execute it 5 times, so it'd be good to encapsulate it inside of a method that parameters for the fireDate. I've shown how you could do it for Monday.

                  UILocalNotification *notification = [[[UILocalNotification alloc] init] autorelease];
                  
                  // Set this to an NSDate that is for the time you want, on Monday
                  notification.fireDate = fireDate;            
                  
                  // Repeat every week
                  notification.repeatInterval = NSWeekCalendarUnit;
                  

                  这篇关于UILocalNotification 应该在每个工作日重复,但也会在周末触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Xcode 4.2:尝试使用越狱的 iPhone 3G 进行开发时出现 下一篇:故事板 - UITabBarController

                  相关文章

                  最新文章

                • <i id='cH3h6'><tr id='cH3h6'><dt id='cH3h6'><q id='cH3h6'><span id='cH3h6'><b id='cH3h6'><form id='cH3h6'><ins id='cH3h6'></ins><ul id='cH3h6'></ul><sub id='cH3h6'></sub></form><legend id='cH3h6'></legend><bdo id='cH3h6'><pre id='cH3h6'><center id='cH3h6'></center></pre></bdo></b><th id='cH3h6'></th></span></q></dt></tr></i><div id='cH3h6'><tfoot id='cH3h6'></tfoot><dl id='cH3h6'><fieldset id='cH3h6'></fieldset></dl></div>

                  <small id='cH3h6'></small><noframes id='cH3h6'>

                        <bdo id='cH3h6'></bdo><ul id='cH3h6'></ul>
                      <legend id='cH3h6'><style id='cH3h6'><dir id='cH3h6'><q id='cH3h6'></q></dir></style></legend>
                      <tfoot id='cH3h6'></tfoot>