以下是粘贴板更改事件的通知观察器,我需要它来处理复制的选定文本
[[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]);
}
问题是 [通知userInfo] 在iOS 6上返回nil,尽管它在iOS 5上运行良好。
答案 0 :(得分:0)
嗯,这适用于iOS 6
NSLog(@"%@", [[UIPasteboard generalPasteboard] string]);