我'm trying to update the string in the subtitle of a delivered notification (alert), I'用这样做_2618429这样做:
[NSTimer scheduledTimerWithTimeInterval:5.0
target:self
selector:@selector(updateSubtitle)
userInfo:nil
repeats:YES];
- (void)updateSubtitle
{
[[NSUserNotificationCenter defaultUserNotificationCenter].deliveredNotifications
enumerateObjectsUsingBlock:^(NSUserNotification *notification, NSUInteger idx, BOOL *stop) {
notification.subtitle = @"new subtitle";
}];
}
代码每5秒正确执行一次 . 但是通知警报中显示的副 Headers 不会改变 .
有没有办法强迫"redraw"像 setNeedsDisplay
或类似的东西?
谢谢 .
1 回答
我知道这篇文章有些陈旧,但我最近试图弄清楚同样的事情,但最终需要删除现有的通知并添加一个具有相同 Headers 的新通知 .
我在创建通知的标识符字段时使用NSUUID,然后使用(在Swift中)类似的东西找到现有的NSUUID: