【发布时间】:2012-02-26 17:11:36
【问题描述】:
我花了半天时间阅读所有“如何取消本地通知”问题和答案。 毕竟,我想出了自己的解决方案,但显然它不起作用。 我有一个包含所有预定通知的表格视图....
在我拥有的 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 第三次测试[8921:207]-[__NSCFType encodeWithCoder:]:无法识别的选择器发送到实例 0x890ae90 程序收到信号“SIGABRT”。
如果我可以完全确定要取消的通知,为什么它会给我呢?
【问题讨论】:
标签: objective-c uitableview ios5 xcode4 uilocalnotification