2 chenyang2005 chenyang2005 于 2016.03.08 11:49 提问

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
devmiao   Ds   Rxr 2016.03.08 12:48
chenyang2005
chenyang2005 这个链接也是我发的
接近 2 年之前 回复
chenyang2005
chenyang2005   2016.03.09 09:39

大神在哪里???大神在哪里???

chenyang2005
chenyang2005   2016.03.09 14:18

已经解决了,已经解决了,已经解决了

Csdn user default icon
上传中...
上传图片
插入图片