简体   繁体   English

我如何在iPhone中进行计划事件警报?

[英]How i can make Schedule event alarm in iphone?

How i can make Schedule event alarm in iphone? 我如何在iPhone中进行计划事件警报?

Schedule for 365 days and five time in the day. 安排365天,一天中的五个时间。 every days have different time 每一天都有不同的时间

use this idea 用这个主意

    NSLog(@"clicked");
NSDate* date = [NSDate date];

NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];


[formatter setDateFormat:@"HH:MM:SS"];                 //seting the date formater object
[formatter setTimeStyle:NSDateFormatterMediumStyle];

NSString* CorrectTime = [formatter stringFromDate:date];     //storing the date into string
NSLog(@"Current Time %@",CorrectTime);

[lab setText:CorrectTime];

 if(!isValue){

        NSTimeInterval seconds=10;       //if 24 * 60 * 60 its for after 1day i.e. 24hrs,60min,60seconds
        NSDate *changed;
        changed = [date addTimeInterval:seconds];

        af60= [formatter stringFromDate:changed];
        NSLog(@"Changed time after 60s %@",af60);

    isValue = TRUE;

NSDate *d = [NSDate dateWithTimeIntervalSinceNow: 5.0];
NSTimer *t = [[NSTimer alloc] initWithFireDate:d interval: 2 target: self selector:@selector(timerTick) userInfo:nil repeats:NO];
NSRunLoop *runner = [NSRunLoop currentRunLoop];
[runner addTimer:t forMode: NSDefaultRunLoopMode];
[t release];
 }

} }

 - (void)timerTick{
   NSLog(@"Time Out********************************&&&&&&&&&&&&&&&&&&&&");
    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"alert" message:@"Yours Time Out" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"ok",nil];
   [alert show];

  }

here i added only 10 sec, after 10 sec it wil pops alertview. 在这里,我只添加了10秒,在10秒后它将弹出alertview。 like this u should fire your alarm 像这样,你应该触发警报

You need to set the notification.repeatInterval 您需要设置notification.repeatInterval

like this 像这样

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

This will help you http://useyourloaf.com/blog/2010/9/13/repeating-an-ios-local-notification.html Thanks, Naveed 这将帮助您http://useyourloaf.com/blog/2010/9/13/repeating-an-ios-local-notification.html谢谢,Naveed

You need to set the notification.repeatInterval for your code 您需要为您的代码设置notification.repeatInterval

like this 像这样

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

This will help you http://useyourloaf.com/blog/2010/9/13/repeating-an-ios-local-notification.html Thanks, Naveed 这将帮助您http://useyourloaf.com/blog/2010/9/13/repeating-an-ios-local-notification.html谢谢,Naveed

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM