English 中文(简体)
我如何创建“当地统一标准”,每两分钟就公布一次。
原标题:How do I create a UILocalNotification that notifies every two minutes
  • 时间:2011-08-01 07:00:00
  •  标签:
  • iphone
  • ipad

因此,我基本上试图制定一种能够不断向当地通知的信号。

到目前为止,我已经:

- (void)scheduleNotification {

    [reminderText resignFirstResponder];
    [[UIApplication sharedApplication] cancelAllLocalNotifications];

    Class cls = NSClassFromString(@"UILocalNotification");
    if (cls != nil) {

        UILocalNotification *notif = [[cls alloc] init];
        notif.fireDate = [datePicker date];
        notif.timeZone = [NSTimeZone defaultTimeZone];

        notif.alertBody = @"Your building is ready!";
        notif.alertAction = @"View";
        notif.soundName = UILocalNotificationDefaultSoundName;
        notif.applicationIconBadgeNumber = 1;

        NSInteger index = [scheduleControl selectedSegmentIndex];
        switch (index) {
            case 1:
                notif.repeatInterval = NSMinuteCalendarUnit;
                break;
            case 2:
                notif.repeatInterval = NSMinuteCalendarUnit*2;
                break;
            default:
                notif.repeatInterval = 0;
                break;
        }

        NSDictionary *userDict = [NSDictionary dictionaryWithObject:reminderText.text
                                                forKey:kRemindMeNotificationDataKey];
        notif.userInfo = userDict;

        [[UIApplication sharedApplication] scheduleLocalNotification:notif];
        [notif release];
    }
}

我试图这样做,我可以每2分钟(当我确定案件2时)和每1分钟(当我确定案件1时)收到通知。 唯一的问题是...... 页: 1 我怎么会这样做,以便每2分钟通知它?

问题回答

只有当你确定当地统一私法协会的重复间财产时,你才能使用NSCalendarUnit确定的日历单位。 你可以不使用习俗单位或操纵这些单位,因此,你无法利用通知重复间隔财产做你想要做的事情。

为了每2分钟安排通知,你很可能在不同时间安排多次通知(2分钟)。 您可以设立地方情报处,然后安排:

[[UIApplication sharedApplication] scheduleLocalNotification: localNotification];

then modify the fireDate property (by adding your repeat interval), and then schedule it again with the same code. You can repeat this in a loop however many times you need to repeat the notification.





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签