youdesou 2016-03-08 03:49 采纳率: 0%
浏览 1405

IOS 闹钟不响应,请看代码

IOS 闹钟不响应,请看代码:

  • (void)btnclock_click:(UIButton *)button {     UILocalNotification *notification=[[UILocalNotification alloc] init];

    
    if (notification!=nil) {

        
        notification.fireDate=[NSDate dateWithTimeIntervalSinceNow:20];
//10秒后通知
        

        notification.repeatInterval=kCFCalendarUnitMinute;
//循环次数,kCFCalendarUnitWeekday一周一次

        
        notification.applicationIconBadgeNumber=4;
//应用的红色数字
        

        notification.soundName= UILocalNotificationDefaultSoundName;//声音

        
        notification.alertBody=@"通知内容";
//提示信息 弹出提示框

        
        notification.alertAction = @"打开";  
//提示框按钮

        
        //notification.hasAction = NO;
//是否显示额外的按钮,为no时alertAction消失

    
         NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"someValue" forKey:@"someKey"];
        

        notification.userInfo = infoDict;
//添加额外的信息

      
        [[UIApplication sharedApplication] scheduleLocalNotification:notification];
        

    }
}

响应闹钟:AppDelegate.m

  • (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {     application.applicationIconBadgeNumber = 0;

    if (notification) {

        NSLog(@"didFinishLaunchingWithOptions");

        UIAlertView *alert =  [[UIAlertView alloc] initWithTitle:nil message:notification.alertBody delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

        [alert show];

    }
}

死活不响应,请各位大神帮忙解答下,不甚感激!

  • 写回答

3条回答

  • devmiao 2016-03-08 04:48
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号