我是一名有用的助手,可以翻译文本。
我花了半天时间阅读所有关于“如何取消本地通知”的问题和答案。最终,我想出了自己的解决方案,但显然它不起作用。我有一个包含所有预定通知的表格视图...
在H文件中,我有:
然后在M文件上:
如果我点击“确定”按钮,会出现以下信息: 2012-02-04 03:34:48.806 Third test[8921:207] -[__NSCFType encodeWithCoder:]: unrecognized selector sent to instance 0x890ae90 程序接收到“SIGABRT”信号。
如果我能够完全确定要取消的通知,为什么还会出现这个问题?
我花了半天时间阅读所有关于“如何取消本地通知”的问题和答案。最终,我想出了自己的解决方案,但显然它不起作用。我有一个包含所有预定通知的表格视图...
在H文件中,我有:
@property (strong, nonatomic) UILocalNotification *theNotification;
然后在M文件上:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSArray *notificationArray = [[UIApplication sharedApplication] scheduledLocalNotifications];
theNotification = [notificationArray objectAtIndex:indexPath.row];
NSLog(@"Notification to cancel: %@", [theNotification description]);
// NSLOG Perfectly describes the notification to be cancelled. But then It will give me "unrecognized selector"
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Local Reminder"
message:@"Cancel local reminder ?"
delegate:self
cancelButtonTitle:@"No"
otherButtonTitles:@"Yes", nil];
[alertView show];
[alertView release];
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
NSLog(@"Cancel");
}else{
NSLog(@"Ok");
[[UIApplication sharedApplication] cancelLocalNotification:theNotification];
}
}
如果我点击“确定”按钮,会出现以下信息: 2012-02-04 03:34:48.806 Third test[8921:207] -[__NSCFType encodeWithCoder:]: unrecognized selector sent to instance 0x890ae90 程序接收到“SIGABRT”信号。
如果我能够完全确定要取消的通知,为什么还会出现这个问题?
presentLocalNotificationNow:
呈现的通知。我花了一年时间才弄清楚! - Nick Farina