4
A
回答
2
如果你有,你必須每天解僱通知的時候,你應該這樣做
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [[NSDateComponents alloc] init];
for (NSMutableArray * arrDay in self.namaztimes) {
NSLog(@"Alarm Array: %@", arrDay);
int count=[arrDay count];
if(!count){
continue;
}
int day =0;
int month=0;
int year=0;
int hour =0;
int minutes=0;
// NSArray *arrDates=[[NSMutableArray alloc] initWithCapacity:1];
for (int i=0;i<3;i++) {
NSString * dayTime=[arrDay objectAtIndex:i ];
if (i==0) {
day = [dayTime intValue];
}else if(i==1){
month = [dayTime intValue];
}else if(i==2){
year = [dayTime intValue];
}
}
for (int i=3;i<count;i++) {
NSString * dayTime=[arrDay objectAtIndex:i ];
hour = [[dayTime substringToIndex:2] intValue];
minutes = [[dayTime substringFromIndex:3] intValue];
[components setDay:day];
[components setMonth:month];
[components setYear:year];
[components setMinute:minutes];
[components setHour:hour];
NSDate *myNewDate = [calendar dateFromComponents:components];
[self scheduleNotificationForDate:myNewDate];
}
}
[components release];
[calendar release];
然後從這裏它會連接到主通知燒製法
[self scheduleNotificationForDate:myNewDate];
-(void) scheduleNotificationForDate: (NSDate*)date {
/* Here we cancel all previously scheduled notifications */
[[UIApplication sharedApplication] cancelAllLocalNotifications];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = date;
NSLog(@"Notification will be shown on: %@ ",localNotification.fireDate);
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.alertBody = @"Your Notification Text"; //[NSString stringWithFormat:@"%@",date];
localNotification.alertAction = NSLocalizedString(@"View details", nil);
/* Here we set notification sound and badge on the app's icon "-1"
means that number indicator on the badge will be decreased by one
- so there will be no badge on the icon */
localNotification.repeatInterval = NSDayCalendarUnit;
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber = -1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}
1
我知道這個問題在很久以前就被問到了,我加了這個,因爲它對一些人會有幫助。
如果您想通知選定日期,請按照此tutorial。這將有所幫助。
相關問題
- 1. 如何爲選定的日期和時間設置鬧鐘?
- 2. 如何在android中設置特定日期的鬧鐘?
- 3. 在選定的時間和日期設置鬧鐘
- 4. 在Android中將鬧鐘設置爲特定日期和時間
- 5. Android - 如何在特定日期前X天設置鬧鐘
- 6. 如何在特定日期範圍內設置鬧鐘?
- 7. 如何在ios日曆中設置EKEvent中的特定鬧鐘?
- 8. Android設置多個長日期鬧鐘
- 9. 如何設置android鬧鐘觸發,直到特定日期
- 10. 在代碼中設置iPhone鬧鐘?
- 11. 如何在ios中的選定工作日(星期一,星期日)設置鬧鐘。 (Localnotification)
- 12. 如何在動態日期和時間設置鬧鐘?
- 13. 如何在android中爲日曆事件設置多個鬧鐘?
- 14. 如何在android中使用鬧鐘管理器設置星期一鬧鐘?
- 15. 具有特定日期的Android鬧鐘設置
- 16. 如何在ios中設置鬧鐘?
- 17. 如何在android java中設置鬧鐘
- 18. 如何在iOS中設置鬧鐘?
- 19. 如何在Android中設置鬧鐘?
- 20. 鬧鐘設置
- 21. 是否需要多個鬧鐘才能設置不同日期的鬧鐘?
- 22. 爲鬧鐘設置鈴聲
- 23. 如何在特定日期設置鬧鐘並每週重複計劃
- 24. 設置日期和時間從各自的選擇器到設置鬧鐘
- 25. 如何在同一時間將鬧鐘設置爲多個日期一次
- 26. 根據數據庫中的日期設置鬧鐘
- 27. 訪問並設置iphone默認鬧鐘
- 28. 設置特定工作日的鬧鐘。但是每天鬧鐘響起
- 29. 如何在日曆中設置EKEvent沒有鬧鐘
- 30. 在我的鬧鐘應用程序中設置多個鬧鐘
檢查[this](http://www.icodeblog.com/2010/07/29/iphone-programming-tutorial-local-notifications/)和[Local Notification Tutorial](http://reecon.wordpress。 COM/2010/11/12 /設定-A-提醒-使用-uilocalnotification式-IOS -4-目標c /)。還請檢查此[Apple文檔](https://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html)。 –