0

这是粘贴板更改事件的通知观察者,我需要它来处理复制的选定文本

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(receiveClipBoardNotification:)
                                             name:@"UIPasteboardChangedNotification"
                                           object:nil];

下面是选择器方法receiveClipBoardNotification 的实现:

- (void) receiveClipBoardNotification:(NSNotification *) notification {

//    NSMutableArray *typesAddedKey = [[notification userInfo] objectForKey:@"UIPasteboardChangedTypesAddedKey"];
//    pasteBoardItemType = [typesAddedKey objectAtIndex:0];        

    NSLog(@"%@", [notification userInfo]);
}

问题是[notification userInfo]在 iOS 6 上返回 nil,尽管它在 iOS 5 上完美运行。

4

1 回答 1

0

好吧,这适用于 iOS 6

NSLog(@"%@", [[UIPasteboard generalPasteboard] string]);
于 2012-12-10T11:06:51.080 回答