Objective c 如何在xcode中从tableview中删除本地通知
在我的应用程序中,我在表视图中显示本地通知 代码如下:Objective c 如何在xcode中从tableview中删除本地通知,objective-c,ios,cocoa-touch,uilocalnotification,Objective C,Ios,Cocoa Touch,Uilocalnotification,在我的应用程序中,我在表视图中显示本地通知 代码如下: NSArray *notificationArray=[[UIApplication sharedApplication] scheduledLocalNotifications]; UILocalNotification *notif = [notificationArray objectAtIndex:indexPath.row]; [cell.textLabel setText:notif.alertBody]; [cell.deta
NSArray *notificationArray=[[UIApplication sharedApplication] scheduledLocalNotifications];
UILocalNotification *notif = [notificationArray objectAtIndex:indexPath.row];
[cell.textLabel setText:notif.alertBody];
[cell.detailTextLabel setText:[notif.fireDate description]];
我想从表视图中删除所选行,我该怎么做 如果要删除该行,请从模型中删除
[yourModelArray removeObjectAtIndex:indexPath.row];
编辑:
重新加载表视图:
[tableView reloadData];
如果您询问如何删除特定的本地通知,当用户点击特定单元格时,则:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSArray *notificationArray=[[UIApplication sharedApplication] scheduledLocalNotifications];
UILocalNotification *notificationToCancel= [notificationArray objectAtIndex:indexPath.row];
[[UIApplication sharedApplication] cancelLocalNotification:notificationToCancel];
[yourTable reloadData];
}
请想一想您正在标记什么,这与
xcode
IDE无关,或者只是单元deleteRowsAtIndexPaths:withRowAnimation:
什么样的示例代码?你有你的项目,不管你面临什么问题,我们都回答了。我猜你遇到了模型数据数组的问题。不要直接在tablview单元格中显示,先将notif添加到模型数组,然后在tableview上显示。如何将通知添加到模型数组?@ArulKumar:意思是,如果需要删除通知,可以这样做。如果您只需要删除行,请使用anoop的答案。问题是什么?