你好,我和UILocalNotification有问题。我从服务器接收通知,并将Json Array存储在Mutable array中。像这样:
idnoty *通知id *通知标题
当我尝试此代码时:
UILocalNotification *notif;
NSMutableArray *notifications = [[NSMutableArray alloc] init];
for(int i=0 ; i<[idnoty count]; i++){
notif=[[UILocalNotification alloc]init];
if (notif == nil) return;
NSLog(@" H LOOP %i",i);
notif.fireDate = [NSDate date];
notif.timeZone = [NSTimeZone defaultTimeZone];
[[UIApplication sharedApplication] cancelAllLocalNotifications];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
[localNotification setHasAction:YES];
localNotification.timeZone = [NSTimeZone localTimeZone];
localNotification.alertBody = [titlenoty objectAtIndex:i];
localNotification.applicationIconBadgeNumber = i+1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification ];
}最后,当我收到来自服务器的2个或更多通知时。这段代码显示了最后一次通知。
json:代码
content = (
{
active = 1;
descr = sdescr;
entrydate = "2013-05-15";
id = 48;
pid = 11;
title = dasdsad;
},
{
active = 1;
descr = sdescr;
entrydate = "2013-05-16";
id = 49;
pid = 11;
title = MALAKA;
},
{
active = 1;
descr = sdescr;
entrydate = "2013-05-16";
id = 50;
pid = 11;
title = dasdsadsadsadsadsadsadsagdfggffggfdgdfgdfgdfgdfgdfgdfgdfgdf;
}
);
"total_rows" = 3;
}谢谢
发布于 2013-05-15 18:08:30
您不应该每次都在循环内调用[UIApplication sharedApplication cancelAllLocalNotifications]。
https://stackoverflow.com/questions/16561824
复制相似问题