【发布时间】:2012-02-26 19:13:55
【问题描述】:
我的应用程序用于从数据库中选择不同的文本数据。我们有每天显示本地通知的功能。
我正在使用以下代码:
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
localNotif.fireDate = [itemDate addTimeInterval:-(minutesBefore*60)];
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertBody = @"Hey"; // Can I select random message for this notification?
localNotif.alertAction = NSLocalizedString(@"View Details", nil);
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:item.eventName forKey:ToDoItemKey];
localNotif.userInfo = infoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
现在是否可以为本地通知显示不同的文本数据?怎么样?
【问题讨论】:
-
你能举一个你想要显示的不同文本的例子吗?
-
@Leena:随便说一句:localNotif.alertBody = @"Hey";否则 localNotif.alertBody = @"你好"; else localNotif.alertBody = @"哦,太好了";
-
创建一个字符串数组,然后随机选择字符串并将其分配给您的 localnotification.alertbody
-
但我每天都在重复。所以它会每天显示相同的消息。我想显示不同的消息。
-
我不认为这是可能的。
标签: iphone objective-c cocoa-touch ios4 uilocalnotification