zoukankan      html  css  js  c++  java
  • iphone 定时提醒

    //定时提醒
    -(void)schedulNotificationWithYear:(int)y andMonth:(int)m andDay:(int)d andHour:(int)h andMintu:(int)mi andMsg:(NSString *)msg{
        
        // Set up the fire time
        NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
        NSDateComponents *dateComps = [[NSDateComponents alloc] init];
        [dateComps setDay:d];
        [dateComps setMonth:m];
        [dateComps setYear:y];
        [dateComps setHour:h];
    // Notification will fire in one minute
        [dateComps setMinute:mi];
    [dateComps setSecond:0];
        NSDate *itemDate = [calendar dateFromComponents:dateComps];
        [dateComps release];
        
        UILocalNotification *localNotif = [[UILocalNotification alloc] init];
        if (localNotif == nil)
            return;
        localNotif.fireDate = itemDate;
        localNotif.timeZone = [NSTimeZone defaultTimeZone];
        
    // Notification details
        localNotif.alertBody = msg;
    // Set the action button
        localNotif.alertAction = @"查看";
        
        localNotif.soundName = UILocalNotificationDefaultSoundName;
        //    localNotif.applicationIconBadgeNumber = 1;
        
    // Specify custom data for the notification
        NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"someValue" forKey:@"someKey"];
        localNotif.userInfo = infoDict;
        
    // Schedule the notification
        [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
        [localNotif release];
    }
    
    在AppDelegate.m中添加如下代码,相当于回调函数
    
    
    - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification*)notif {
    
        UITextView *tv = (UITextView *)[[application keyWindow] viewWithTag:11];
        NSString *status = [NSString stringWithFormat:@"%@", [notif description]];
        tv.text = status;
        //添加处理代码
    }
  • 相关阅读:
    Hadoop 倒排索引
    Hadoop 电话通信清单
    Hadoop 多表关联
    Ubuntu 16.04下Samba服务器搭建和配置(配截图)
    Hadoop 单表关联
    Hadoop 排序
    Hadoop 数据去重
    Hadoop 学生平均成绩
    MapReduce计算模型的优化
    win7系统下dos界面无法自由调整大小
  • 原文地址:https://www.cnblogs.com/lm3515/p/2546101.html
Copyright © 2011-2022 走看看