从Webview复制内容时,UIPasteboardChangedNotification调用了两次

时间:2018-10-16 07:29:06

标签: ios notifications uipasteboard

存在一个问题,当从Web视图复制内容时,通知“ UIPasteboardChangedNotification”将被调用两次。有谁知道为什么以及如何解决它?

1 个答案:

答案 0 :(得分:0)

从网络视图复制内容时,此通知确实可能触发2次。您可以检查是否由于添加了某个项目而触发了通知:

- (void) pasteboardChangedNotification:(NSNotification *)notification {
    if(notification.userInfo != NULL && [notification.userInfo objectForKey:UIPasteboardChangedTypesAddedKey] != NULL) {
        //item added
    }
    else {
        //nothing added
    }
}