gpt4 book ai didi

ios - 从选择表格单元格设置本地通知

转载 作者:行者123 更新时间:2023-11-28 21:30:12 25 4
gpt4 key购买 nike

其实这个问题已经被问了很多次了。但我对这些感到困惑。这个我试过了。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if([[cell.btn backgroundImageForState:UIControlStateNormal]isEqual:[UIImage imageNamed:@"unchecked.png"]])
{
[cell.btn setBackgroundImage:[UIImage imageNamed:@"checked.png"] forState:UIControlStateNormal];

UILocalNotification *reminderNote =[[UILocalNotification alloc]init];
reminderNote.soundName = @"music.mp3";
[[UIApplication sharedApplication] scheduleLocalNotification:reminderNote];
reminderNote.alertBody = @"Wish birthday to :%@",[kAppDelegate.commString objectAtIndex:indexPath.row];

NSString *date =[kAppDelegate.String objectAtIndex:indexPath.row];

NSDate *dateP = [ dateformat dateFromString:date];
components = [[NSCalendar currentCalendar] components:NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear fromDate:dateP];
[components setHour:4];
[components setMinute:59];
[components setSecond:10];

reminderNote.fireDate = [[NSCalendar currentCalendar] dateFromComponents:components];
}

其中单元格是 UITableviewCell 的对象,但没有任何类型的通知。我知道有一个小Bug,请帮我找出来。

最佳答案

  • 将最后一行作为 [[UIApplication sharedApplication] scheduleLocalNotification:reminderNote]; 放在 reminderNote.fireDate 行之后。

  • 记录 reminderNote.fireDate 并检查格式。

希望这对您有所帮助。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if([[cell.btn backgroundImageForState:UIControlStateNormal]isEqual:[UIImage imageNamed:@"unchecked.png"]])
{
[cell.btn setBackgroundImage:[UIImage imageNamed:@"checked.png"] forState:UIControlStateNormal];

UILocalNotification *reminderNote =[[UILocalNotification alloc]init];
reminderNote.soundName = @"music.mp3";
reminderNote.alertBody = @"Wish birthday to :%@",[kAppDelegate.commString objectAtIndex:indexPath.row];

NSString *date =[kAppDelegate.String objectAtIndex:indexPath.row];

NSDate *dateP = [ dateformat dateFromString:date];
components = [[NSCalendar currentCalendar] components:NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear fromDate:dateP];
[components setHour:4];
[components setMinute:59];
[components setSecond:10];

reminderNote.fireDate = [[NSCalendar currentCalendar] dateFromComponents:components];
[[UIApplication sharedApplication] scheduleLocalNotification:reminderNote];
}

关于ios - 从选择表格单元格设置本地通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36401517/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com