每天UILocalNotification如何每天重複UILocalNotification下午5點?以下是我設置自定義時間的代碼。但我想每天通知用戶定製或可能是靜態時間。我正在使用iOS 6.重複下午5時
-(void)scheduleNotification{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"h:mm a"];
NSDate *dateFromString = [[NSDate alloc] init];
dateFromString = [dateFormatter dateFromString:timeStr];
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
localNotif.fireDate = dateFromString;
localNotif.repeatInterval = kCFCalendarUnitDay;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
// Notification details
localNotif.alertBody = @"Reminder is set";
// Set the action button
localNotif.alertAction = @"Ok";
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;
// Specify custom data for the notification
NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:@"Local Push received while running", @"key", nil];
localNotif.userInfo = infoDict;
// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
}
那麼你需要什麼'localNotif.repeatInterval = kCFCalendarUnitDay;'不能做? – 2012-10-31 10:54:43
它只顯示徽章。警報視圖不顯示。 –
請點擊此鏈接http://stackoverflow.com/questions/11303413/iphone-daily-local-notifications –