我要设定一周中选定天数的提醒 。
可以是周日(mon、tue、wed、thu或fri)、周末(sat、sun)或每日。
我如何使用本地通知来做到这一点?
我要设定一周中选定天数的提醒 。
可以是周日(mon、tue、wed、thu或fri)、周末(sat、sun)或每日。
我如何使用本地通知来做到这一点?
如果你有时间每天发布通知,你应该这样做
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];
then from here it will connect to the main notification firing method
[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];
}
我知道这个问题是很久以前问的,我之所以要补充这个问题,是因为它对一些人有帮助。
如果您想要通知选定天数, 请跟随此 < a href=" http://www. icodeblog.com/2010/ 07/ 29/ iphone- programing-tutor- local- notifications/" rel=“ nofollow” >tutument 。 这将很有帮助 。
For a basic app with nonconsumable in-app purchases, has anyone figured out best practices for using SKPaymentQueue s restoreCompletedTransactions? Observations I know it s recommended to always ...
I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...
I have a UITextField that is a subview of a UITableViewCell. When my view loads, I want the text field to become first responder. I have a pointer to the text field in the table cell, so to do this I ...
I ve been working on adding in-app purchases and was able to create and test in-app purchases using Store Kit (yay!). During testing, I exercised my app in a way which caused the app to crash mid ...
In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...
Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...
I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...
Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...